javascript - jquery constraint div to max window height -


i using code achieve div browser (window) height

$(document).ready(function(){      $('#div') .css({'height': (($(window).height()))+'px'});  }); 

but if want div constraint height user maximum window height(max device limit)? above code determine current window height, once user resizing window or not opening max window size, got change , failed.

try :

$(document).ready(function(){     $(window).resize(function(){         $('#div') .css({'height': (($(window).height()))+'px'});     }).trigger('resize') }); 

with that, binding event when screen resize. recalculate window height.

the .trigger() part ensure happen once when dom ready (it trigger event resize).


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -