I don't know how to break or return from addEventListener
Here I get "Undefined label 'testfunc'" error
testfunc:
test.addEventListener("click", function(){
console.log("TEST")
break testfunc
})
Here I get "TEST" everytime i click but I want it only to console.log("TEST") only once
function testfunc(){
test.addEventListener("click", function(){
console.log("TEST")
return
})
}
you can create some variable and put there flag (true/false), for example:
let isClicked = false;
function testfunc(){
test.addEventListener("click", function(){
if (isClicked) return;
console.log("TEST")
isClicked = true
})
}