automatically detect web browser window width change?

ajsie picture ajsie · Jan 31, 2010 · Viewed 53.4k times · Source

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?

Answer

PetersenDidIt picture PetersenDidIt · Jan 31, 2010

Try the resize event

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