I have a mousenter/mouseleave function that swaps out content when the element is being hovered over. however instead of it firing only on mouseenter it seems to keep continuously firing. I have created a jsfiddle here so hopefully it will be easier to understand.
I have a mousenter/mouseleave function that swaps out content when the element is being
Share
Inside your
rotate_start()androtate_reset()functions you are triggering a hover event via this line:Per JQuery docs,
hover()method binds handlers for bothmouseenterandmouseleaveevents. You’re basically applying recursion unintentionally, ashoveris fired as the mouse moves.A simple fix for this is to replace
.attr('hover','true');with.data('hover',true);Here is a scalable solution which should accomplish your objective:
HTML:
CSS:
JQuery:
Demo: http://jsfiddle.net/AlienWebguy/EY8mM/1/