I have a div with elements (h3, img, p) inside. I want to use jQuery to detect when the user is hovering over this div, then to switch the element class in this div.
I am using the following code:
$('.entry').bind({ mouseover: function() { $('.readMore').toggleClass('inverted'); }, mouseleave: function() { $('.readMore').toggleClass('inverted'); } });
This works as expected when hovering over a div only. If you hover over an element inside a div (e.g. .entry h2 ), it will disable the class as if it left the parent div ( .entry ), but it is actually inside it. Elements do not float inside div.entry which I thought could throw it away. I tried $(".entry *") and $(".entry, .entry *") , but both have similar problems.
Any thoughts?
source share