I have the following script that works when I use it in Google Console, but when I implement the custom script live, it will display: none; the class regardless of the conditions.
let notes = document.querySelectorAll(".elementor-element-befe370")[0];
let dents = document.querySelectorAll("elementor-element-1b86ce2");
dents.forEach; {
if (document.body.textContent.includes("No, +1")) {
notes.style.display = 'none';
} else {
notes.style.display = "block";
}
};
If the dents text contains "No, +1" then I am looking to remove the notes element
The syntax of your code is incorrect. The for each loop takes in a function. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
let notes = document.querySelectorAll(".elementor-element-befe370")[0];
let dents = document.querySelectorAll("elementor-element-1b86ce2");
dents.forEach((dent) => {
if (dent.textContent.includes("No, +1")) {
notes.style.display = 'none';
} else {
notes.style.display = "block";
}
})