仅在移动设备中加载脚本不起作用

问题描述 投票:0回答:1

我找到了一个完全基于我期望的脚本。它会检查是否存在特定的cookie并运行某些条件。一直到这里,一切都好

$(document).ready(function(){
  if ($.cookie('bas_referral') == null ) {
      alert('There is no yet');
      console.log('setting cookie');
   var ref = document.referrer.toLowerCase();  
   // set cookie  
   var cookURL =  $.cookie('bas_referral', ref, { expires: 365 }); 
  } 
  else {alert('Now it has!')}; 
 });  

现在,我想以某种分辨率加载这个相同的脚本,但是我写的代码不起作用。 = \

$(document).ready(function(){
if ($(window).width() < 767) {

  if ($.cookie('bas_referral') == null ) {
      alert('There is no yet');
      console.log('setting cookie');
   var ref = document.referrer.toLowerCase();  
   // set cookie  
   var cookURL =  $.cookie('bas_referral', ref, { expires: 365 }); 
  } 
  else {alert('Now it has!')};
}

else {alert('Large screen');} 
 });  

有谁知道为什么,可以帮助我?从现在开始,我感谢你! =]

javascript jquery cookies mobile
1个回答
1
投票

if ($(window).width() < 767)

不是声明。但if ($(window).width() < 767)

© www.soinside.com 2019 - 2024. All rights reserved.