How to track window size with jquery

Track window size with jquery is simple.You can use this method to achive many things in your website.

Jquery

$(document).ready(function(e) {
 $win_w=$(window).width();
 $win_h=$(window).height();
 $('#window-width').html("Window Width : "+$win_w);
 $('#window-height').html("Window Height : "+$win_h);   
});
$(window).resize(function(){
 $win_w=$(window).width();
 $win_h=$(window).height();
 $('#window-width').html("Window Width : "+$win_w);
 $('#window-height').html("Window Height : "+$win_h); 
 });

HTML

Resize window to check realtime window size

Download File Used in this example View Live Demo

No comments:

Post a Comment