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 Answers
+ 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