Xah Lee, 2005-06
This javascript example prints the current time.
to show time.
First, the “Click Me” button is a plain HTML tag, like this:
<p><button id="x09b5a">Click Me</button> to show time.</p>
The javascript is like this:
function myGetTime() { var dd = new Date(); var hh = dd.getHours(); var mm = dd.getMinutes(); var ss = dd.getSeconds(); alert("The time is now: " + hh + ":" + mm + ":" + ss); } document.getElementById("x09b5a").onclick = myGetTime;blog comments powered by Disqus