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? Quote 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) Quote 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 (edited) $(this).$('.remove_cart_item').fadeToggle(); ?? The hidden element is a child of the hover element. Edited May 5, 2013 by 1internet Quote 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... Quote 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...
Solution kicken Posted May 6, 2013 Solution 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.