I have tried two types of iterating techniques but both produce the same error:
addClass is not function
First example using for:
function game(){
var cards = $('.card');
function initialize(){
for(var x = 0; x < cards.length; x++) {
cards[x].addClass('wtf');
}
};
};
Second try using each:
function game(){
var cards = $('.card');
function initialize(){
//Add random key values to pairs of cards
$.each( cards ,function(i, ele) {
ele[i].addClass('wtf');
});
};
};
What is the correct way to manipulate these type of arrays?
$('.card').addClass('wtf');jQuery goes through each one for you, you don't have to. Am I missing something?