September 23, 2021 09:25 am GMT
Original Link: https://dev.to/101samovar/how-to-add-a-class-to-the-element-896
How to add a class to the element?
Theres some site.
Theres an element on that site.
Theres a class named orange.
We need to set the className property of the object.
Thats all.
const element = document.getElementById('element');element.className = 'orange';
.orange { color: orange;}
We have got an element with added class.
I hope you found this article useful, if you need any help please let me know in the comment section.
See you next time. Have a nice day!
Subscribe to our channel:
https://www.youtube.com/c/Samovar101
Original Link: https://dev.to/101samovar/how-to-add-a-class-to-the-element-896
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To