change img src and unbind hover on menu selection jquery -



change img src and unbind hover on menu selection jquery -

first question using stackoverflow! yay!

i have site i'm developing. uses images menu options, , on hover, i've changed img src in jquery

when click menu want go to, want image on hover remain there. did this: $("#one").click(function(){ $(this).attr('src', 'images/hover1.jpg'); $(this).unbind('mouseleave mousehover');

so successful upon menu click, cant hover image go away, , doesnt hover anymore (cause unbinded it) - binding upon menu click wasnt working.

any suggestions?

first of all. think recommend create css solution here.

i checked out javascript file , did modifications in browser. build possible working solution.

$(document).ready(function() { var hoverfuncin = function(){ $(this).attr('src', $(this).attr('src').replace(/(\d)(\.jpg)$/g,'$12$2')); }; var hoverfuncout = function(){ $(this).attr('src', $(this).attr('src').replace(/2(\.jpg)$/g,'$1')); }; var clicktoggle = function(e){ $('.selected').hover(hoverfuncin,hoverfuncout).removeclass('selected').mouseout(); $(e.currenttarget).addclass('selected').unbind('mouseleave mousehover'); } $('nav img').hover(hoverfuncin,hoverfuncout); $("#one").click(function(e){ clicktoggle(e); ...

jquery menu hover image src

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -