javascript - I can't get mouse out to work -


so have function prevent body scrolling when sidebar hovered. problem is, can't mouseout function work properly.

var currentscroll=0; function lockscroll(){     $(window).scrolltop(currentscroll); }   $(document).ready(function (){          $(".sidebarholder, .commentswrapper").hover(function (){             currentscroll=$(window).scrolltop();             $(window).bind('scroll',lockscroll);          })      }) 

my question is, how unbind on mouseout?

if this, stops working altogether.

    $(".sidebarholder, .commentswrapper").mouseout(function(){         currentscroll=$(window).scrolltop();         $(window).unbind('scroll');      }) 

jquery's hover() has built in "hover off", might helpful:

   $(".sidebarholder, .commentswrapper").hover(      function (){ // hover on        currentscroll=$(window).scrolltop();        $(window).bind('scroll',lockscroll);      },      function (){ // hover off        currentscroll=$(window).scrolltop();        $(window).unbind('scroll',lockscroll);      }    ) 

http://api.jquery.com/hover/


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -