如果我的屏幕宽度小于960像素,我如何让jQuery做一些事情?无论窗口大小如何,下面的代码始终会触发第二个警报:if (screen.width < 960) { alert('Less than 960');}else { alert('More than 960');}
3 回答

catspeake
TA贡献1111条经验 获得超0个赞
使用jQuery获取窗口的宽度。
if ($(window).width() < 960) {
alert('Less than 960');
}
else {
alert('More than 960');
}
添加回答
举报
0/150
提交
取消