Question: 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');

    })

```

Answer: 
jQuery's `hover()` has built in "hover off", which might be helpful:

```
   $(".sidebarholder, .commentswrapper").hover(
     function (){ // hover over
       currentScroll=$(window).scrollTop();
       $(window).bind('scroll',lockscroll);
     },
     function (){ // hover off
       currentScroll=$(window).scrollTop();
       $(window).unbind('scroll',lockscroll);
     }
   )

```

<http://api.jquery.com/hover/>
Have you tried 

```
     $(document).ready(function () {
        $(".sidebarholder, .commentswrapper").hover(function () {
           currentScroll = $(window).scrollTop();
           $(window).bind('scroll', lockscroll);

        }, function () {
           currentScroll = $(window).scrollTop();
           $(window).unbind('scroll');

        })
     })

```