我有這樣的劇本,我希望在窗口只有不到768px
console.log('less than 768px');
但我的腳本作品一貫窗口時,更多的則是768px
,請幫助我的人:(
var width = $(window).width();
$(window).on('resize',function(){
if (width < 768){
console.log('less than 768px');
}else{
console.log('nothing');
}
});
時,該工作......和你在哪裏獲得寬度的值?! – 2014-12-02 13:17:00
您可以發佈可以使用的值的原點: var width = document.documentElement.clientWidth || document.body.clientWidth || window.innerWidth; – 2014-12-02 13:17:07
查看更新請 – 2014-12-02 13:18:44