Ask coding questions

← Back to all posts
How do i make heading change in HTML?
LlamaBoii

I'm trying to make a website where I want the text to show my roles and change it every 2 seconds automatically. Where it shows my [roles] for example: "I'm a YouTuber" and I want the "YouTuber" to change into "Developer" every 2 seconds [YouTuber and Developer are the roles].

How do i do that?

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
LlamaBoii
Comments
hotnewtop
Coder100

use setInterval to make the interval, and use HTML to change it.
I recommend using span tags, like this:

And for your js code:

A working repl: https://replit.com/@Coder100/SuperiorPlaintiveDebuggers-landing-page-carousel#script.js

LlamaBoii

@Coder100 Thanks

NFadhlurrahman

In the script.js file, write the following code:

LlamaBoii

@NFadhlurrahman thanks man