Javascript examples for DOM:Quiz
Use the DOM to assign an onclick event to the <button> element. Clicking the button should trigger displayDate().
<!DOCTYPE html> <html> <body> <button id="myBtn">Try it</button> <p id="demo"></p> <script> document.getElementById("myBtn").onclick = function(){displayDate()}; function displayDate() {/* w w w . ja v a 2 s. com*/ document.getElementById("demo").innerHTML = Date(); } </script> </body> </html>