0
Innerhtml content is not updating with this jquery code. Any help?
var x = $("#clock"); function addZero(i) { if (i < 10) { i = "0" + i; } return i; } function clock(){ var nd = new Date(); // var hh, mm, ss; var hh = nd.getHours(); var mm = addZero(nd.getMinutes()); var ss = addZero(nd.getSeconds()); x.html( hh + ":" + mm + ":" + ss); } $(document).ready(setInterval (clock (),1000)); //setInterval(clock(),1000);
6 Respostas
+ 1
yes. its working. thanks a lot.
0
plz check output mm and ss.
I am sure that is null value
if your #clock element is input. u nid to use .val()
if that is other than input elements plz use .text()
0
yes. its output is null value. I used .text() method as well. still no result.
- 1
can u upload code at playground , so I can test
- 1
https://code.sololearn.com/Wo9m6f4WtP38/?ref=app
u nid document ready to get #clock
document ready function is make sure that all elements load finished then start running script