A Simple Example of Real time Time Acquisition in jquery

  • 2021-07-16 01:11:03
  • OfStack

Examples are as follows:


$(document).ready(function(){

function time(){
var date=new Date();
var h=date.getHours();
var m=date.getMinutes();
var s=date.getSeconds();



$('div').eq(0).html(h);
$('div').eq(1).html(m);
$('div').eq(2).html(s);

for(var i=0;i<$('div').length;i++){
if($('div').eq(i).text().length==1){
$('div').eq(i).html(function(index,html){
return 0+html;
});
}
}

}
time();
setInterval(time,1000);
}) ; 

HTML Part

< div > < /div >

< div > < /div >

< div > < /div >


Related articles: