On resize event, get width and display its value - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:resize

Description

On resize event, get width and display its value

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <style>

p {//  w w w  .  j a v  a2 s . c o  m
   color: black;
   font-size: 60px;
}


      </style> 
 </head> 
 <body translate="no"> 
  <p></p> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
  <script>
$(document).ready(function() {
  var winresize = 0;
  $(window).resize(function() {
    winresize = $(window).height();
    onwinResize(winresize);
  });
});
function onwinResize(winresize) {
  $("p").html(winresize + " px");
};
      </script>  
 </body>
</html>

Related Tutorials