<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head>
<body>
<h1>jQuery resize() Method</h1>
<div>Try to resize this window or click on the button (do any one).</div>
<p>Window width is <span></span></p>
<button>Trigger resize Event</button>
<script>
$(document).ready(function(){
$(window).resize(function() {
$("span").text($(window).width() +"px");
});
$("button").click(function(){
$(window).resize();
});
});
</script> </body>
</html>