How to execute a function if url contains "x" in jQuery -


i'd execute function up(); if url contains "invt".

so far have this:

if(window.location.pathname == "/invt/"){   alert("invt"); } 

however, wasn't alerting me. ideas?

i've since got work, answers below.

consider:

$(document).ready(function () {    if(window.location.href.indexof("invt") > -1) { //checks url "invt" (all products contain this)      up();      return;        }       }); 

try this:

if ( window.location.pathname.indexof('invt') >= 0 ) {  alert("invt"); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -