I am making a website in which it has a auto timer, which adds numbers every second (in js). I added for the timer the id ‘timer’. I also want it to auto-scroll but I have not worked on that yet.
I tried to do this:
var timer = document.getElementById('timer')
var time = 1
while (true) do{
await delay(1000)
timer.innerHTML = timer.innerHTML + time
time = time + 1
I also still need to add auto-scroll too
2
Answers
Use the
scroll
function to scroll to {x, y}. Get the width from thescrollWidth
property.Your current approach is not valid JS code, you should use
setInterval
to acheive the repeated actionYou can follow this function:
Here is a sample implementation in html