When the button is clicked, trigger myFunction() with an event. - Javascript DOM

Javascript examples for DOM:Quiz

Description

When the button is clicked, trigger myFunction() with an event.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Click Me</button>

<p id="demo"></p>

<script>
function myFunction() {// ww  w .  java 2s  .  c  o m
    document.getElementById("demo").innerHTML = "Hello World";
}
</script>

</body>
</html>

Related Tutorials