Source Code:
(back to article)
Submit
Result:
Report an issue
<button id="myButton">Click me</button> <script> const button = document.getElementById('myButton'); function alertClick() { alert("Button clicked!"); button.removeEventListener('click', alertClick); // Remove listener after first click } button.addEventListener('click', alertClick); </script>