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);

19th Oct 2017, 12:42 AM
Sudheendra
Sudheendra - avatar
6 Réponses
19th Oct 2017, 4:51 AM
Sudheendra
Sudheendra - avatar
+ 1
yes. its working. thanks a lot.
19th Oct 2017, 5:21 AM
Sudheendra
Sudheendra - avatar
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()
19th Oct 2017, 1:10 AM
林偉雄
林偉雄 - avatar
0
yes. its output is null value. I used .text() method as well. still no result.
19th Oct 2017, 2:58 AM
Sudheendra
Sudheendra - avatar
- 1
can u upload code at playground , so I can test
19th Oct 2017, 2:59 AM
林偉雄
林偉雄 - avatar
- 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
19th Oct 2017, 4:56 AM
林偉雄
林偉雄 - avatar