The jQuery below doesn’t work but when the var link is equal to file:///C:/Users/USER/Desktop/test%20page/Home.html it does so is there a jquery where IF the window.location.href; ends with the specified variable such as var link ="/Home.html"; then execute javascript.
$(document).ready(function(){
var winloc = window.location.href; // file:///C:/Users/USER/Desktop/test%20page/Home.html
var link = "/Home.html";
if(winloc==link){
$('ul li a').remove();
}
});
<ul>
<li><a href="Home.html">Home</a></li>
</ul>
I would use
lastIndexOfand get the last part of the url which is/Home.htmlin you case and check it withlinkvar.See my DEMO.
Code below,