I want to do he following, but it does not work:
if(pathname == '/ik/services/' || '/ik/recruitment/'){
//run function
}
It is completely ignoring my if statement and executes the code for all pages...
I want to do he following, but it does not work:
if(pathname == '/ik/services/' || '/ik/recruitment/'){
//run function
}
It is completely ignoring my if statement and executes the code for all pages...
You would have to do something like this:
if(pathname == '/ik/services/' || pathname == '/ik/recruitment/'){
//run function
}
Your || '/ik/recruitment/'
would always be truthy, and therfor the code within your if-statement will always run.
Try
if(pathname == '/ik/services/' || pathname == '/ik/recruitment/'){
OR
jQuery inArray
Example
var arr = ['/ik/services/','/ik/recruitment/'];
if($.inArray(pathname , arr) !== -1)
This has nothing to do with jQuery, it's just a normal JS "error". You need to compare both strings with the variable:
if (pathname == 'foo' || pathname == 'bar')
Try this:
if((pathname == '/ik/services/') || (pathname == '/ik/recruitment/')){
//run function
}
try doing
if(pathname == '/ik/services/' || pathname == '/ik/recruitment/'){
//run function
}