jQuery resize() trigger resize event

Description

jQuery resize() trigger resize event

View in separate window

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

<p>Window resized <span>0</span> times.</p>

<button>Trigger resize event for the window</button>

</body>
</html>



PreviousNext

Related