JQuery

Use jQuery to do something to a DIV when the user clicks outside of it

Sometimes you wanna do something such as when you click a div a part that you hide, shown and when click outside of if you wanna hide again . Following code do what exactly you want.

        $(document).mouseup(function (e) {

            var container = $("your_selector");
       
            if (!container.is(e.target) // if the target of the click isn't the container...
                && container.has(e.target).length === 0) // ... nor a descendant of the container
            {
                // do something you want (hide,show,remove, change class anything you want) Ex: container.hide()
               
            }
        });

Don’t scroll whole page while scrolling

-View-

<html>
  <head>
     <title>Title here</title>
  </head>
  <body>
      <div id="navbar" style="position:fixed;"></div>
      <div id="content>
      <div id="leftColumn"></div>
      <div id="centerColumn"></div>
      <div id="rightColumn"></div>    
  </div>
  </body>
</html>

-Javascript-

    $(window).scroll(function () {
        var scrollTop = $(window).scrollTop();
        if (scrollTop > 0)
            $('#leftColumn, #rightColumn').css('margin-top', scrollTop);
        else
            $('#leftColumn, #rightColumn').css('margin-top', scrollTop);
    });

P.S. Use this code if you just want to scroll center of the page Not left not right content just scroll center content of the page.