Before I get to my question, consider the following code, which seems to work with jQuery:
var $element = $('.input-fieldset');
$element.each(function(){
$(this)[0].classList.add("input-fieldset-awesome");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<fieldset id="pay" class="input-fieldset"></fieldset>
<fieldset id="address" class="input-fieldset"></fieldset>
I discovered that the above seemed to work after first running into problems with this:
var $element = $('.input-fieldset');
$element.classList.add("input-fieldset-awesome");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<fieldset id="pay" class="input-fieldset"></fieldset>
<fieldset id="address" class="input-fieldset"></fieldset>
Which throws an error:
Cannot read property 'add' of undefined
In my struggle to find a solution, I found that someone else had a similar problem here, but in that example, they weren't using jQuery. Also, it was found to be a duplicate question of this, which the top answer suggested that $('.myElement').css('size', '100px');
was possible. But if that should work, then why doesn't this:
$('.input-fieldset').classList.add("input-fieldset-awesome");
That was the first question; my other question is this: in my working solution above, I used "[0]" to de-reference the first element in the $(this) object which I know should have only one element in it, but is that really the best solution? (It seems strange to me that I should need the "[0]" at all...)