function hidenv() {
var txt = document.querySelector(".wapf-grand-total")[0].innerText;
if (txt === "$260") {document.querySelector("button").style.display = "none";
}
}
hidenv();
<input class="wapf-grand-total">
<button>button</button>
I want to hide/show the button when a element have a diferent value of $260 but with my code it only happen when i refresh the page. I need that this function run when the value change on real time but i don't know how do it.
function hide() {
var txt = document.querySelectorAll(".wapf-grand-total")[0].innerText;
if (txt !== "$260") {document.querySelector("button").style.display = "none";
}
}
hide();