Write program to display current time on a web page.
Trigger the display from a button
Use Date class.
<!DOCTYPE html> <html> <body> //from w w w . j a va 2 s . co m <h2>My First JavaScript</h2> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display Date and Time.</button> <p id="demo"></p> </body> </html>