0
$(".test").hover(function(){
  $(this).addClass("move");        
})

上面的jQuery需要一些修复。我的CSS选择器目前是这样的:

.test .selectme

并将鼠标悬停在.test当前元素上会导致:

.test.move .selectme

我试图在将鼠标悬停在.test元素上时得到这个:

.test .selectme.move

所以基本上当我.selectme.move鼠标悬停在parent .test.

4

2 回答 2

5

您需要在selectme里面找到项目,menu然后将类添加到它

$(".menu").hover(function(){
  $(this).find('.selectme').addClass("move"); //You may use toggleClass('move') if you want to remove the class when the mouse leaves menu item
})
于 2013-07-04T08:03:27.873 回答
1
$(".test").hover(function(){
    $('.selectme',this).addClass("move"); //This is simpler, find the selectme that's inside of .test
})
于 2013-07-04T09:14:42.050 回答