Reputation:
I have a nav element that onmouseover I'd like to disable the onmouseover of nearby images.
I was thinking that I'd just loop through and collect the images and set their onmouseover to '' and then onmouseout of the nav element set the images onmouseover back to what it was.
Is there a better way to just get the images onmouseover function to turn off/on through onmouseover/onmouseout of the nav elements?
Upvotes: 0
Views: 2340
Reputation:
Okay, I think all of those things would work, but that turned out not to be my issue. The issue was that something being set in the images mouseover function was still affecting the navigation once the images were rolled over, even if they were no longer active, being displayed, or had no mouseover events.
Thanks though.
Upvotes: 0
Reputation: 27811
Why not do the following:
onmouseover
events on all images to a single functiononmouseout
events on all images to a single functionvar imageInFocus = null;
if(imageInfocus == null)
, assign the current image name to it, and handle that image.onmouseout
, just assign null back to imageInFocus
, so it will be available for the next image.Upvotes: 3
Reputation: 8701
Use jQuery. Something like this should do:
$("#id_of_your_element").hover(function(){
$(".other_elements_class").unbind("mouseover").unbind("mouseover");
}, function(){
$(".other_elements_class").hover(your_mouseover_function, your_mouseout_function);
});
Upvotes: 0