I’ve got a cookie I am creating with jQuery named ‘testCookie’. I want to check to see if any of these VALUES DO NOT exist, if they do NOT (or are equal to or less than -1) I want to do something, the code below currently does nothing and it assumes as if the code isn’t even there and loads everything after the if-statement regardless of cookies value, any ideas?
if ($.cookie('testCookie').indexOf('shopping','pricegrabber','nextag','shopzilla')<=-1) {
The
indexOffunction can only take one string at a time. To do this you would need to have multiple clauses in yourifstatement, joined with&&:if(cookieValue.indexOf('shopping') == -1 && cookieValue.indexOf('pricegrabber') == -1)You can add all of your conditions into that
ifstatement. The&&means “if this and this” etc. etc.