Document addEventListener() Method - Click to Change the background color of the document's <body> element: - Javascript DOM

Javascript examples for DOM:Document addEventListener

Description

Document addEventListener() Method - Click to Change the background color of the document's <body> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<script>
document.addEventListener("click", function(){
    document.body.style.backgroundColor = "red";
});/*www  .ja v a2s .  c o  m*/
</script>

</body>
</html>

Related Tutorials