<div class="custom-class1">
<div class="custom-class2" id="custom-id1">hello 1</div>
<div class="custom-class3" id="custom-id2">hello 2</div>
<div class="custom-class4" id="custom-id3">hello 3</div>
</div>
And I want to Deactivate/Conceal the Second [div] (id="custom-id2") , if the URL of the page includes the string ?specificpost.
For instance: if my webpage's URL is
http://www.samplewebsite.com/article_1.html?specificpost
then the custom-id2 div
should not be visible.
However, if the URL is simply
http://www.samplewebsite.com/article_1.html
then the custom-id2 div
should appear normally.
<script>
let target = document.getElementById("custom-id2");
if(window.location.href.includes("?specificpost")){
target.style.display = "none";
}
</script>
My JavaScript code isn't functioning as expected.