HYUTS HYUTS - 3 months ago 5x
jQuery Question

How can I add a class using jQuery in this loop

I would like to add a class to each of my cardCount elements using jQuery.

if (i == 13 || i == 26 || i == 39) {
for (ii=0; ii<13; ii++){
cardCount += "<span>" + cardOrder[ii] + "</span>"}

Thank you.


for (ii=0; ii<13; ii++){
cardCreate += "<span class=" + changeClass + '>' + cardOrder[ii] + "</span>";


If you want to use jquery after all you may try this:


Note that the code above will apply the class "myClass" to all of your spans.

But, do this is better:

cardCount += "<span class='myClass'>" + cardOrder[ii] + "</span>"}