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
Post a Comment