0
JS how to create a condition if the button is NOT pressed
How to create a condition if the button is NOT pressed. Help please
2 Réponses
+ 1
So I'm guessing you are attaching some sort of event for clicking somewhere, and your goal is to check that the click was NOT on a specific button?
<button id="btn">Click</button>
In JavaScript:
window.addEventListener("click", function (evt) {
if (evt.target.id != "btn") {
// Code here
}
});
0
Logical operator NOT !