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

8th Mar 2020, 10:33 PM
Федор
2 ответов
+ 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 } });
9th Mar 2020, 2:00 AM
Zeke Williams
Zeke Williams - avatar
0
Logical operator NOT !
8th Mar 2020, 11:58 PM
Ignas Juodžiukynas
Ignas Juodžiukynas - avatar