0

What is the most neatest way to check whether a user is hovering over an object after hovering out of a different object. I.e. If user mouses out of object A onto object B, how would you suggest I go about monitoring this? I don't really like the idea of continously monitoring the mouses position when it moves, though it may be the only option...

Bob-ob
  • 1,560
  • 4
  • 18
  • 34

2 Answers2

2

check out this fiddle

http://jsfiddle.net/aVz7Q/4/

A simple hover event in jQuery can accomplish this, with the help of some variable work, you can store what the previous element and current element are.

Dennis Martinez
  • 6,344
  • 11
  • 50
  • 67
1

Events bubble up. Add en event listener for the parent element of A & B. In that listener you can record on mouseout the original target of the event as the latest object that was mousedout (using something like $(this).data("latestMouseout",latestTarget), Best way to get the Original Target). On mousein, you can check your conditions and see if latest mouseout target and mousein target meet the conditions you need.

I know this is a little vague, but so is your question. If this helps great. If not, feel free to ask clarifying questions.

Community
  • 1
  • 1
Pyro979
  • 202
  • 1
  • 10