我想要更改var screenWidth;当调整窗口到手机。当我加载时它正在工作,但在调整大小时没有。我在这里错过了什么?我正在使用jssor滑块。我可以在控制台中看到screenWidthFunction()正在工作。Javascript - 更改变量的大小不工作与JSSOR滑块
JS:
var screenWidth;
function screenWidthFunction() {
if($(window).innerWidth() < 768) {
screenWidth = 960;
console.log(screenWidth);
} else {
screenWidth = 1920;
console.log(screenWidth);
}
}
//var screenWidth = 1920;
screenWidthFunction();
function ScaleSlider_home_1() {
var refSize_home_1 = jssor_home_1_slider.$Elmt.parentNode.clientWidth;
if (refSize_home_1) {
refSize_home_1 = Math.min(refSize_home_1, screenWidth);
jssor_home_1_slider.$ScaleWidth(refSize_home_1);
}
else {
window.setTimeout(ScaleSlider_home_1, 30);
}
}
ScaleSlider_home_1();
$(window).bind('load',function(){
//screenWidthFunction();
ScaleSlider_home_1();
});
$(window).bind('resize',function(){
screenWidthFunction();
ScaleSlider_home_1();
});
$(window).bind('orientationchange',function(){
//screenWidthFunction();
ScaleSlider_home_1();
});
这是我的小提琴:http://jsfiddle.net/df58scsk/1/
显示你的HTML和CSS – ewwink
请看这里:http://jsfiddle.net/df58scsk/1/ –
它与全宽大小,你的意思是固定的宽度,如果'<768' – ewwink