I would like the divs to show if the content contains the same word in both X and Y, otherwise I would like it to be hidden. So in the example below the first 2 Y elements would show and the others would be hidden.
Can anyone help with this, please?
<div class="X">Apples</div>
<div class="Y">Apples</div>
<div class="Y">Apples, Bannanas, Pears</div>
<div class="Y">Bannanas, Pears</div>
<div class="Y">Pears</div>
myCriteria() {
var element = document.getElementsByClassName("X, Y");
{
if (X === Y) {
element.style.display = "block";
} else {
element.style.display = "none";
}
}
},