Reputation: 49
For example, I have a div element everywhere on the domain. and I want to delete it on ost page but not on the main page . for example I want to show it on www.spiele33.de
but delete it on http://www.spiele33.de/uncategorized/moto-x3m-4-winter/
So, I want to do it with javascript
<script>
var currentUrl = window.location.href;
if (currentUrl.indexOf('.de/') != currentUrl.length - 4) // if it is not home page
{
var x = document.getElementsByClassName("entry-title h2-simulate-h1");
x.style.display= "none";
}
</script>
but it does not work
Upvotes: 0
Views: 70
Reputation: 1148
location.pathname
contains everything after the domain, so check for location.pathname === '/'
.
Upvotes: 2