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