Reputation: 2538
currently im using jquery to get the URL path
var href = document.location.pathname;
the path im looking for is something like /clients/invoice/details/DynamicID/DynamicID
i need to check if jquery if the href contains /clients/invoice/details/ in that order in the path to do something. Can someone please help me - i tried the following
if(href.match('/\/clients/invoice/details/\/')) {
}
but i think im doing something wrong.
Upvotes: 0
Views: 4359
Reputation: 3231
You can use the includes()
method.
if(href.includes('/clients/invoice/details/')) {
}
ref: includes()
Upvotes: 0
Reputation: 228
var href = window.location.href;
if(href.indexOf(‘/clients/invoice/details/') > -1){
//your code
}
You can do with a simple indexOf function instead of complex regex
Upvotes: 4