$(selector).resize(function)
<!DOCTYPE html>
<html>
<head>
<title> jQuery resize() method </title>
<script src = "/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>
<script>
var i = 0;
$(document).ready(function(){
$(window).resize(function(){
$("span").text(i += 1);
var res = "Width = " + $(window).width() + "<br/>Height = " + $(window).height();
$('#para').html(res);
});
});
</script>
<style>
span {
font-weight: bold;
color: red;
font-size: 20px;
}
</style>
</head>
<body>
<h2> This is an example of using the jQuery resize() method. </h2>
<p> Try to resize your browser's window to see the effect. </p>
<p> You have resized the window <span id = "s1"> 0 </span> times.</p>
<p id = "para"> </p>
</body>
</html>