JS getelementbyid


getelementbyid() method accesses the specific form element by its ID, and then you may revise its content. Follow example uses getelementbyid() to show your local time dynamically.

<script type="text/javascript">
function currenttime()
{
var tm = document.getElementById('tm');
var current_time = new Date();
tstr = current_time.toTimeString();
var str = "" + tstr + ""
tm.innerHTML = str;
}
</script>
<br>
<div id="tm">Current Time Place Holder</div>
<br>
<input type=button onclick="currenttime();" value="Show Current Time"
style="font-size:17px">


Current Time Place Holder