In this example, I have an input text field that contains a datetime value set with jQuery.
http://jsfiddle.net/D4Hu9/
HTML:
<input id="foo" name="foo" type="text" value="" size="55" />
JS:
jQuery(document).ready(function()
{
var now = new Date();
jQuery('#foo').val(now.toString());
});
How can I update this value every 5 seconds from jQuery?
function updateTime() {
var now = new Date();
jQuery('#foo').val(now.toString());
}
setInterval(updateTime, 5000); // 5 * 1000 miliseconds
Here's the fiddle: http://jsfiddle.net/28Tgz/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With