1internet Posted May 5, 2013 Share Posted May 5, 2013 $('.cart_item').hover(function(){ $('.remove_cart_item').fadeToggle(); }); So the issue is that when I hover over the div class cart_item, all the divs with class cart_item show the hidden div class remove_cart_item. How do I get it to just show for the div its hovering over? Link to comment https://forums.phpfreaks.com/topic/277676-dont-want-to-affect-all-class-elements/ Share on other sites More sharing options...
Jessica Posted May 5, 2013 Share Posted May 5, 2013 Use $(this) Link to comment https://forums.phpfreaks.com/topic/277676-dont-want-to-affect-all-class-elements/#findComment-1428465 Share on other sites More sharing options...
1internet Posted May 5, 2013 Author Share Posted May 5, 2013 $(this).$('.remove_cart_item').fadeToggle(); ?? The hidden element is a child of the hover element. Link to comment https://forums.phpfreaks.com/topic/277676-dont-want-to-affect-all-class-elements/#findComment-1428485 Share on other sites More sharing options...
Jessica Posted May 5, 2013 Share Posted May 5, 2013 So add the children selector... Link to comment https://forums.phpfreaks.com/topic/277676-dont-want-to-affect-all-class-elements/#findComment-1428488 Share on other sites More sharing options...
kicken Posted May 6, 2013 Share Posted May 6, 2013 $('.remove_cart_item', this)That sets the context so it will only search nodes under the this node, which would be the div that is currently being moused over. Link to comment https://forums.phpfreaks.com/topic/277676-dont-want-to-affect-all-class-elements/#findComment-1428596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.