Frage

The code to make a div height equal to its width below:

$('div').height($('div').width());

However if you manually resize the browser window the height will not update - you need to refresh the page. Any idea how to correct it?

War es hilfreich?

Lösung

You need to bind your code on the window.onresize event :

window.onresize=function(){
  $('div').height($('div').width());
};

The doc : http://www.w3schools.com/jsref/event_onresize.asp

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top