我想做他以下,但它不起作用:
if(pathname == '/ik/services/' || '/ik/recruitment/'){
//run function
}
它完全忽略了我的 if 语句并执行所有页面的代码......
我想做他以下,但它不起作用:
if(pathname == '/ik/services/' || '/ik/recruitment/'){
//run function
}
它完全忽略了我的 if 语句并执行所有页面的代码......
你必须做这样的事情:
if(pathname == '/ik/services/' || pathname == '/ik/recruitment/'){
//run function
}
您|| '/ik/recruitment/'
将永远是真实的,因此您的 if 语句中的代码将始终运行。
尝试
if(pathname == '/ik/services/' || pathname == '/ik/recruitment/'){
或者
jQueryinArray
例子
var arr = ['/ik/services/','/ik/recruitment/'];
if($.inArray(pathname , arr) !== -1)
这与jQuery无关,它只是一个普通的JS“错误”。您需要将两个字符串与变量进行比较:
if (pathname == 'foo' || pathname == 'bar')
试试这个:
if((pathname == '/ik/services/') || (pathname == '/ik/recruitment/')){
//run function
}
尝试做
if(pathname == '/ik/services/' || pathname == '/ik/recruitment/'){
//run function
}