JS - addEventListener() method

0 votes
85 views
added Jul 3, 2019 in Javascript by LC Marshal Captain (25,770 points)
<p id="test">Click to test addEventListener() method</p>

<script>
document.getElementById("test").addEventListener("click", myFunction);

function myFunction() {
  document.getElementById("test").innerHTML = "Yeayyy, I'm clicked";
}
</script>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...