<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Executing a Function on Resize Event in jQuery</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <style> p{ padding: 22px; font: 22px sans-serif; background: yellow; } </style> <script> $(document).ready(function(){ $(window).resize(function() { $(window).bind("resize", function(){ $("p").text("Window width: " + $(window).width() + ", " + "Window height: " + $(window).height()); }); }); }); </script> </head> <body> <p>Launch the output in a fresh tab and adjust the size of the browser window by dragging its corners.</p> </body> </html>