I want to refresh div on each 6 second? I am using this code but why my time is not refreshing ? after page reload it shows current time.
setInterval(function() {
var d = new Date(),
h = d.getHours(),
m = d.getMinutes();
if(h < 10) h = '0' + h;
if(m < 10) m = '0' + m;
$('input[type="time"][value="now"]').each(function(){
$(this).attr({'value': h + ':' + m});
});
}, 3000);
because after first change inupt value changed,
$('input[type="time"][value="now"]') is not working because there is no input tag has value "now"
try this
setInterval(function() {
var d = new Date(),
h = d.getHours(),
m = d.getMinutes();
if(h < 10) h = '0' + h;
if(m < 10) m = '0' + m;
$('input[type="time"]').each(function(){
$(this).attr({'value': h + ':' + m});
});
}, 3000);