jQuery HTML Element How to - Handle window resize event








Question

We would like to know how to handle window resize event.

Answer


<!-- w w w  .j  a  va  2  s  . com-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $(window).resize(function(){
                 console.log("Stop it!");
            });
        });
    </script>
  </head>
  <body>
    <body>
     <div>adsf</div>
    </body>
</html>

The code above is rendered as follows: