Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>This example uses the addEventListener() method to attach a "resize" event on the window object.</p>

<p>Try to resize the browser window.</p>

<p>Window resized <span id="demo">0</span> times.</p>

<script>
window.addEventListener("resize", myFunction);

var x = 0;
function myFunction() {
    var txt = x += 1;
    document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>





Result:
Try it Yourself - © w3schools.com