1
1
12LiCaNtRoP122021-06-28 17:58:43
HTML
12LiCaNtRoP12, 2021-06-28 17:58:43

How to implement this in html?

I often saw on sites how the text changes, as if it were an animation, for example, in the form of a countdown. How to implement it and what is it generally called?
In the comments I will throw a link to the page, as an example, where it is.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Art222222, 2021-06-28
@12LiCaNtRoP12

This can be done via JavaScript. You create a method where the time will change every second (google for help).
Let's say we change the text in the paragraph: We need Id in JavaScript: Create a script tag and inside do this thing:
<p id="timer1">00:00:00</p>

document.getElementById("timer1").innerHTML = "00:00:01";

Well, so that the method is updated every second, we stuff it into some method and write it so that it would be convenient to update the timer like this:
document.getElementById("timer1").innerHTML = hour + ":" + minute + ":" + seconds;
или это:
var dv = ":";
document.getElementById("timer1").innerHTML = hour + dv + minute + dv + seconds;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question