I'm making a cards game, so i need to check if 2 elements (array in table) are the same, i noticed that the only way to do that is with JQuery, but i'm new with these things, i barely control Javascript, jQuery is a hell for me.
My code looks like this
var twoace = "<img src='twoace.png' class='two'>";
var twogold = "<img src='twogold.png' class='two'>";
var onegold = "<img src='onegold.png' class='one'>";
var oneace = "<img src='oneace.png' class='one'>"
// i have a lot more code (sorry for my english) but this is the essential
//initial array
tablecards = [deckcard[0], deckcard[1], deckcard[2], deckcard[3]];
document.getElementById("table1").innerHTML = tablecards[0];
document.getElementById("table2").innerHTML = tablecards[1];
document.getElementById("table3").innerHTML = tablecards[2];
document.getElementById("table4").innerHTML = tablecards[3];
// here i add a card to the table
tablecards.push(handcard[0]);
//now i have this
tablecards = [deckcard[0], deckcard[1], deckcard[2], deckcard[3], handcard[4]];
document.getElementById("table5").innerHTML = tablecards[4];
How do i check if "tablecards[4]" and "tablecards[1]" (or any other) has same class?
tablecards[4].className == tablecards[1].className?deckcard[0]...?.card, for example), then creating the array with$('.card').get()(or[].slice.call(document.querySelectorAll('.card'), 0)). But, that aside, on what event do you want to compare these elements' classes? Onclick,DOMReady/load..?