0

Write a program to display current time in javascript which update itself every millisecond. Moreover. Change the color of......

Write a program to display current time in javascript which update itself every millisecond. Moreover. Change the color of time every half secomds. Need Help

10th Jul 2018, 10:14 AM
ASHISH VERMA
ASHISH VERMA - avatar
3 Réponses
0
For getting the time use... var time = new Date(); To get it every millisecond, put it in a function and call it using... setInterval(myFunction, 1); To display the date/time in an easier format to read, use the modulus % operator. It outputs the remainder when dividing.
10th Jul 2018, 10:19 AM
James
James - avatar
0
James , I think you read only half question . change the color every half seconds?
10th Jul 2018, 10:21 AM
ASHISH VERMA
ASHISH VERMA - avatar
0
To change the colour, add something like this into the function... time.style.color = colors[x]; You'll need to make an array of colours. Then you can configure x however you like -- a loop, or using Math.random().
10th Jul 2018, 10:25 AM
James
James - avatar