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;
<div id="tm">Current Time Place Holder</div>
<input type=button onclick="currenttime();" value="Show Current Time"

Current Time Place Holder

endmemo.com © 2024  | Terms of Use | Privacy | Home