admin管理员组

文章数量:1429561

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();
});

本文标签: javascriptJquery only affect one element in a class being hoveredStack Overflow