I'd like to execute the function up(); if the url contains "invt".
So far I have this:
if(window.location.pathname == "/invt/"){
alert("invt");
}
However, this wasn't alerting for me. Any ideas?
I've since got this to work, thanks to the answers below.
Consider:
$(document).ready(function () {
if(window.location.href.indexOf("invt") > -1) { //checks url for "invt" (all products contain this)
up();
return;
}
});
"/invt/"with no text before or after. See answers below for usage of.indexOf()