Attach a function to the resize event: - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:resize

Description

Attach a function to the resize event:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
x = 0;//from   w  ww .  j a v a  2s .  c  om
$(document).ready(function(){
    $(window).resize(function(){
        $("span").text(x += 1);
    });
});
</script>
</head>
<body>

<p>Window resized <span>0</span> times.</p>
<p>resize your window.</p>

</body>
</html>

Related Tutorials