Reputation: 6780
Here is what I have so far:
var hoveredElement; //none per default
;(function($){
$.fn.isHovered = function(){
return (hoveredElement.length && $( this )[0] === hoveredElement[0] );
};
})(jQuery);
$(document).mouseover( function(e){
hoveredElement = $(e.target);
});
$(document).mouseover( function(e){
console.log( $(this).isHovered() );
});
Basically I have the following structure:
<div id='one'>
<div id="two">
<div id="three">
three
</div>
</div>
</div>
When I mouse over two, i'd like to return true whether it is #two or #three that I am mousing over.
How do i accomplish this?
Upvotes: 1
Views: 110
Reputation: 26183
Try to look into mouseenter, and mouseleave it should give you what you are looking for
Upvotes: 1
Reputation: 32748
Use the jQuery .hover()
API: http://api.jquery.com/hover/ and you should be able to view the current object via $(this)
.
Something like:
$('div').hover(
function() { console.log('hovering over %o', $(this) },
function() { console.log('leaving') }
);
Upvotes: 1