Suppose you have a webpage that keeps refreshing, like so – how can you display a text-counter that counts to 10 ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simple javascript would work.
use the function setinterval() to run some code (you can chose the time interval in miliseconds).
An example of this is here:
http://www.w3schools.com/jsref/met_win_setinterval.asp
Combine this with the getElementById function
and a div like so
(or instead of the div update a text input box like on the w3 example)
I’ve refrained from writing the code for you, but writing it should be good practice and more valuable for you.
P.S. Iam & Dave answered the question which was posed in your title – the title is slightly inaccurate. Better would be “In JavaScript how would you change the inner html of the body of a webpage at regular intervals”