我正在尝试让我的窗口调整大小,但我必须每次更新页面才能使其工作。有没有办法可以更新动态??
$(document).ready(function() {
var $window = $(window);
function checkWidth() {
var window_size = $window.width();
if(window_size> 1820){
$('.22').addClass('size33');
$('.22').removeClass('size22');
} else {
$('.22').removeClass('size33');
$('.22').addClass('size22');
}
}
// Execute on load
checkWidth();
// Bind event listener
$(window).resize(checkWidth);
});
答案 0 :(得分:0)
var div = document.body.selectElementbyId("div id")
window.addEventListener('resize', function() {
var window_size = $window.width();
if(window_size> 1820){
$('.22').addClass('size33');
$('.22').removeClass('size22');
} else {
$('.22').removeClass('size33');
$('.22').addClass('size22');
}
document.getElementbyId("div id").style.width = window_size;
}
}, true);