I am trying to use an each() function and every time the class appears in the table it gets the information within that section.
It is doing the loop x3 but the information i am asking for is only getting from the first instance.
<td class="approved_player">
<span first_role="1" role="Damage" class="icon_damage"></span>
<a class="class_monk">Sickli</a>
</td>
After it has read the information it updates the json array 1 in either damage or not.
var classes = {
classes: [{
"mage": 0
}, {
"warlock": 0
}, {
"rogue": 0
}, {
"paladin": 0
}, {
"deathknight": 0,
"deathknight damage": 0
}, {
"monk": 0,
"monk damage": 0
}, {
"priest": 0,
"priest damage": 0
}, {
"druid": 0,
"druid damage": 0
}, {
"shaman": 0,
"shaman damage": 0
}]
};
$("td.approved_player").each(function (i, obj) {
var player = $("a[class^='accountLink class_']").attr('class').split('_')[1];
var role = $("span[first_role='1']").attr('role').toLowerCase();
$.each(classes, function (key, data) {
$.each(data, function (index, data) {
if (player == data) {
if (role == 'damage') {
data[1] = 1;
} else {
data[0] = 1;
}
}
});
});
$("div#output").append(i + ' appoved class ' + player + ' role ' + role + '<br/>');
});
$.each(classes, function (key, data) {
$.each(data, function (index, data) {
console.log('index', data);
});
});
I am working on this here: http://jsfiddle.net/EXwsy/1/
Thanks for any help.