+ 1
How do i add a class in an ID?, and if it cant be done, how can i get element by class name?
How can I add a class to an id? I have tried it several times and apparently it cannot be, I tried to add a class to another class with javascript, but it turns out that it is somewhat complicated to obtain an element with getElementsByClassname, something about which returns an array and it should be traversed etc, but I go back to the problem at the beginning, could someone give me an example of how it should be done correctly?
4 Réponses
+ 7
Sam Vásquez
Try to use .getElementById(youridhere)
This will help you :)
0
Wait, what did you mean? Did you ask how do you combine a class to an ID?
0
Yes, how add a class to an id
0
Piyush[21 Dec❤️] but, if i use getElementById, i dont can add class with javascript later :(