我有以下代码,它在窗口加载时设置div的高度:
$(window).bind("load", function() {
var
windowHeight = $(window).height(),
callerPrimaryHeight = $('.caller-primary-nav').outerHeight(),
callerSecondaryHeight = $('.caller-secondary-nav').outerHeight(),
callerFooterHeight = $('.caller-footer').outerHeight(),
callerHeight = windowHeight - callerPrimaryHeight - callerSecondaryHeight - callerFooterHeight;
positionCallers();
function positionCallers() {
$('.caller-block').outerHeight(callerHeight);
}
});
如何在窗口调整大小时调用此函数?我知道函数是$('window').resize();
但是如何才能在窗口外加载positionCallers()
函数?
答案 0 :(得分:0)
你可以绑定多个这样的事件:
$(window).bind("load resize", function() {
//..........all your code here......
}).resize();
但你也需要一个doc ready处理程序,当dom准备好你的代码时把它放到:
$(function(){
$(window).bind("load resize", function() {
//..........all your code here......
}).resize();
});