javascript - Jquery only affect one element in a class being hovered - Stack Overflow

Not sure if this is possible.I want to select all elements with a class name and only affect the one e

Not sure if this is possible. I want to select all elements with a class name and only affect the one element being hovered at that time and not the whole class. i can't use ids since they are a lot.

 $('.hideme').hover(function(){
        $('.hideme').hide();
    });

and then.

<div class='hideme'></div>

when the above hides, the following shouldn't hide.

<div class='hideme'></div>
<div class='hideme'></div>
<div class='hideme'></div>

Not sure if this is possible. I want to select all elements with a class name and only affect the one element being hovered at that time and not the whole class. i can't use ids since they are a lot.

 $('.hideme').hover(function(){
        $('.hideme').hide();
    });

and then.

<div class='hideme'></div>

when the above hides, the following shouldn't hide.

<div class='hideme'></div>
<div class='hideme'></div>
<div class='hideme'></div>
Share Improve this question asked Nov 1, 2013 at 8:29 RelmRelm 8,29520 gold badges69 silver badges114 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

If you try to hide by using clss name, then DOM will hide all the element with same name.

So you have to use this keyword for selecting current hovered element.

Try following:

$('.hideme').hover(function(){
        $(this).hide();
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745534632a4631850.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信