Myles
Myles

Reputation: 812

if or statement unexpected token

I've attempting to write an in or statement, and in all honesty have never used one before. I'm trying to use the following snippet of code:

$(document).ready(function () {
  if(window.location.href.indexOf("invt") > -1 || window.location.href.indexOf("shopcart") > -1)) { // if URL contains invt or shopcart
   $('#carriage-promo').prop('id','newid');
     }
       });

But it keeps returning errors no matter what I try!

Any suggestions?

Upvotes: 1

Views: 75

Answers (2)

Paddyd
Paddyd

Reputation: 1870

if(window.location.href.indexOf("invt") > -1 || window.location.href.indexOf("shopcart") > -1))

You have one too many closing brackets )

Try:

if(window.location.href.indexOf("invt") > -1 || window.location.href.indexOf("shopcart") > -1)

Upvotes: 2

Joe Taras
Joe Taras

Reputation: 15399

( ) are unbalanced.

if(window.location.href.indexOf("invt") > -1 ||
   window.location.href.indexOf("shopcart") > -1)

I removed the last ) at the end of your if statement

Upvotes: 2

Related Questions