So I have this function to prevent the body scrolling when the sidebar is hovered. The problem is, I can't get the mouseout function to 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 do I unbind it on the mouseout?
If I do this, it just stops working altogether.
$(".sidebarholder, .commentswrapper").mouseout(function(){
currentScroll=$(window).scrollTop();
$(window).unbind('scroll');
})