+ 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 Odpowiedź
+ 4
document.className = "name" Or document.classList.add("name")
8th Sep 2020, 4:54 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar