Search code examples
javascriptjquerybrowserwindowdetect

automatically detect web browser window width change?


i know that you with $(window).width() can get the size of the web browser.

i want to detect when the user change the size of his web browser so i could readjust the columns width. is there a way to automatically detect this or do i have to use setTimeinterval to loop and see if it has changed?


Solution

  • Try the resize event

    $(window).resize(function() {
      console.log('window was resized');
    });