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); } )
Comments
Post a Comment