2
When an element has more than one class it works if you use document.getElementsByClassName
passing only one of the classes?
If I have an element like:
<div class="class1 class2 class3 ..."></div>
I can take this element this way?
document.getElementByClassname("class1")[i];
And if I do element.className = "class";
this will erase all classes that this element had or will add a?
And to add is using +=
, correct?
works yes...
– Felipe Duarte
And if I do element.classname = "class"; this will erase all the classes that that element had or will add one?
– user83428
It will replace everything. but if you want to add.
– Felipe Duarte
to add is using += right?
– user83428
That’s right, I recommend using this site https://fiddle.jshell.net/, is great for simple testing of this type
– Felipe Duarte
Thanks for your attention, you really helped.
– user83428