+ 4

Why can't I add a class attribute using Javascript [PLEASE HELP]?😩😩😩😩

Am trying to add class attributes to elements I have created using JS but it is not working. It only works when I add an id but I need to use multiple classes for an element so that I can style the elements using CSS according to their groups.

8th Sep 2020, 4:46 PM
David Junior
David Junior - avatar
1 Respuesta
+ 4
document.className = "name" Or document.classList.add("name")
8th Sep 2020, 4:54 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
En tendencia hoy
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
help
0 Votes
AI
2 Votes
APIs
1 Votes