I know there are questions with similars problems, nevertheless I didn't understand how to fix the problem.
I need a solution for this problem: I have a onClick listener added in html document, then, in js I try to remove it but I can't.
Here is my code:
<html>
<head>
</head>
<body>
<div id="my-div" style="background: green" onclick="increase(event)">
0
</div>
<script src="app.js"></script>
</body>
</html>
And in js:
function increase(event){
let div = document.getElementById( event.currentTarget.id );
let number = parseInt(div.innerHTML);
number += 5;
div.innerHTML = number;
div.removeEventListener('click', increase); //but it doesnt get removed...
}
It's like I can't target the event listener added in the html file. How can I target it?