dennismonsewicz
dennismonsewicz

Reputation: 25542

jQuery hover over parent but not children

Is there anyway to interact with the DOM using jQuery that when a user hovers over a div a menu appears, but when they hover over a particular child element inside that parent, nothing happens?

Code so far

$('#player_area:not(< #player_links)').live("mouseenter", function() {
  return $('#album_tracks').slideDown(200);
}).live("mouseleave", function() {
  return $('#album_tracks').hide();
});

Upvotes: 4

Views: 10244

Answers (2)

Stuart Wakefield
Stuart Wakefield

Reputation: 6414

The question is whether it is because you do not wish the action to be repeated with mouseenter events on the children. That is the event is already triggered by the parent and you don't want it to be performed again without first leaving the parent or whether you want the child to not trigger the mouseenter (if it has been positioned outside of the parent).

It seems that your code should work if you merely remove the :not selector.

Edit... Sorry misunderstood... The following fiddle should address what you needed to do

http://jsfiddle.net/q4beS/6/

Upvotes: 0

Guillaume Cisco
Guillaume Cisco

Reputation: 2945

Here is what you need : http://api.jquery.com/mouseover/

mouseenter and mouseleave method.

Check the example demo ;)

Upvotes: 13

Related Questions