我的自定义代码与 WordPress 网站中的其他一些 JavaScript 文件发生冲突。发生冲突的代码在这里。当我删除 jQuery 的 google API 时,除了这段代码之外,一切都工作正常,然后它就停止工作了。我尝试使用 noconflict 修改代码,但没有帮助。也许我做错了。当脚本存在时,它会使地址传送检查器停止工作。<script>$.noConflict();</script><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div id="pondelok" class="msg"><h4>Objednávky dnes prijímame od 11:00 do 21:00.</h4></div><div id="utorok" class="msg"><h4>Objednávky dnes prijímame od 11:00 do 21:00.</h4></div><div id="streda" class="msg"><h4>Objednávky dnes prijímame od 11:00 do 21:00.</h4></div><div id="stvrtok" class="msg"><h4>Objednávky dnes prijímame od 11:00 do 21:00.</h4></div><div id="piatok" class="msg"><h4>Objednávky dnes prijímame od 11:00 do 21:00.</h4></div><div id="sobota" class="msg"><h4>Objednávky dnes prijímame od 11:00 do 21:00.</h4></div><div id="nedela" class="msg"><h4>Objednávky dnes prijímame od 11:00 do 20:00.</h4></div><script>var Now = new Date();var CurrentDay = Now.getDay();var CurrentHrs = Now.getHours();if (CurrentDay == 1 && (CurrentHrs >= 00 && CurrentHrs <= 24)) {$('.msg').hide()$('#pondelok').show();}else if (CurrentDay == 2 && (CurrentHrs >= 00 && CurrentHrs <= 24)) {$('.msg').hide()$('#utorok').show();} else if (CurrentDay == 3 && (CurrentHrs >= 00 && CurrentHrs <= 24)) {$('.msg').hide()$('#streda').show();} else if (CurrentDay == 4 && (CurrentHrs >= 00 && CurrentHrs <= 24)) {$('.msg').hide()$('#stvrtok').show();} else if (CurrentDay == 5 && (CurrentHrs >= 00 && CurrentHrs <= 24)) {$('.msg').hide()$('#piatok').show();} else if (CurrentDay == 6 && (CurrentHrs >= 00 && CurrentHrs <= 24)) {$('.msg').hide()$('#sobota').show();} else if (CurrentDay == 0 && (CurrentHrs >= 00 && CurrentHrs <= 24)) {$('.msg').hide()$('#nedela').show();} else{$('.msg').hide()$('#no_del').show(); }
1 回答
Smart猫小萌
TA贡献1911条经验 获得超7个赞
如果有人遇到同样的问题,我已经通过编辑以下步骤中提到的代码解决了这个问题。
由于 jquery 的双重调用,我删除了下面的代码。
<script>$.noConflict();</script><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
我已将所有
$
符号替换为jQuery
现在我的控制台错误为 0,一切正常。
添加回答
举报
0/150
提交
取消