I'm trying to add a extra class to some elements with a specific class(input-fieldset).
<fieldset id="pay" class="input-fieldset"></fieldset>
<fieldset id="address" class="input-fieldset"></fieldset>
So I did some searches and found this:
var element = document.getElementsByClassName('input-fieldset');
element.classList.add(' input-fieldset-awesome');
I'm trying to add the class input-fieldset-awesome.
But it doesn't work, I get the error:
Uncaught TypeError: Cannot read property 'add' of undefined(anonymous function)
What am I doing wrong?
getElementsByClassName
, try targeting only a particular element – Divertissement