rs19
rs19

Reputation: 667

don't execute jquery if x is in URL

trying to not run this script if the URL is http://convoy.nyc/commerce/show-cart , but something isn't working correctly

if (window.location.indexOf('show-cart') == -1){
}
else {
    window.onload = function(){
    $( ".sqs-money-native" ).append( " per person" );
}

}

Upvotes: 2

Views: 152

Answers (1)

taxicala
taxicala

Reputation: 21759

You almost got it, you where missing the .href:

if (window.location.href.indexOf('show-cart') === -1){
    window.onload = function(){
        $( ".sqs-money-native" ).append( " per person" );
    }
}

Upvotes: 5

Related Questions