这是我的代码:
jQuery(document).ready(function (e) {
resized();
jQuery(window).resize(resized);
function resized() {
wd = parseInt(jQuery(window).width());
if (wd >= 992) {
var wrhei = jQuery(document).height();
jQuery('#menu').height(wrhei);
}
}
});
我希望在调整页面大小时调用函数,而不是在调整函数大小时刷新页面
答案 0 :(得分:1)
这是代码/方法,我在我的项目中使用它并且效果很好。 在文档就绪事件中调用$(window).resize函数,如下所示,
$(document).ready(function () {
$(window).resize(function () {
Resized();
});
});
function Resized()
{
//your code here
}
答案 1 :(得分:0)
您可以尝试:
jQuery(window).on('resize', function(e) {
wd = parseInt(jQuery(window).width());
if (wd >= 992) {
var wrhei = jQuery(document).height();
jQuery('#menu').height(wrhei);
}
});