Document addEventListener() Method - Add many events to the document without overwriting existing events, add two click events to the document - Javascript DOM

Javascript examples for DOM:Document addEventListener

Description

Document addEventListener() Method - Add many events to the document without overwriting existing events, add two click events to the document

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

function myFunction() {//from   ww w.  j a  v a2  s.  c o  m
    console.log("Hello World!")
}

function someOtherFunction() {
    console.log("This function was also executed!")
}
</script>

</body>
</html>

Related Tutorials