以下代码无法正常工作,无法理解原因。我究竟做错了什么?
$(function() {
var advanced = localStorage['advanced-search'];
alert(advanced);//this shows true
if((advanced == "true")|(advanced==true)){
//Code never reaches here
alert('click');
$('#advanced-search').trigger('click');
localStorage['advanced-search'] = false;
}
});
最佳答案
检查“或”运算符。它应该像-
if((advanced == "true")||(advanced==true)){
关于javascript - 如果Windows上的条件无法在JavaScript中加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20741097/