I use jsfiddle run it and the source code is http://jsfiddle.net/eVyjC/12/
I want to add a button to start and stop number changing. I use a div containing
six spans, each has a number.
Then I use createElement to create a input button and set onclick to run the user-defined
function setInterval(keepMove) but it doesn’t work and no any error come out?
And then I test by use alert, to my surprise it run when load the page without click the
button?
My questions are:
1.Why the onclick run first when loading and how to let it run by clicking the button as I expect?
2.I try to add a br to the last span to move the button to the next line, but it doesn’t work. What’s do I wrong and how can I fix it?
Thx you for reading my problem, I have tried to figure it serveral days and try many methods but don’t work.(eg document.write html tag or createElement and Childappend )
1: Instead of:
Do:
That should do the trick.
2: Use
document.write("<br>");I strongly recommend using a javascript library such as jQuery instead of doing all this by hand.