I am having 2 divs:
<div id="player" class="setPlayers">value1</div>
<div id="player2" class="setPlayers">value2</div>
All I want to do is to set the value1 and value2 of the divs to an array for reading later on; I tried out this code, but doesn' t work:
var array = new Array();
$.each($('.setPlayers'), function(key, object) {
console.log(index + ':' + value);
array.push(value);
alert(value);
});
$.each(array, function(index, value) {
console.log(index + ':' + value);
console.log(index + ':' + $(this).val());
});
what' s wrong according to you ?,cheers