Is there a way to dynamically add a class to a div based on the content of another div on the same page?
Here is a snippet of my HTML:
window.addEventListener("load", () => { let b = document.getElementsByClassName('aw-property-data-item')[0].innerHTML; b.includes("Verhuurd"); document.querySelector(".nf-form-cont").classList.add("displaynone"); });
<div class="aw-property-data-item">
<p><strong>Status:</strong> Verhuurd</p>
</div>
<div id="nf-form-7-cont" class="nf-form-cont">
form content goes here
</div>
Although the code successfully adds the class displaynone, it seems to also do so for objects containing "Te Huur" instead of just "Verhuurd." I'm unsure why this is happening and would appreciate any guidance!