Reputation: 115
I want to select all the elements with the class "play" and add them into array "esArreglo".
html file:
<td id="b1" class></td>
<td id="b2" class></td>
<td id="b3" class="play"></td>
<td id="b4" class="play"></td>
code:
$('td.play').each(function() {
notas.push(this.id)};
var esArreglo = notas.join(',');
How can I fix this? Thanks.
Upvotes: 0
Views: 219
Reputation: 160883
You could use jQuery.map
var esArreglo = $('td.play').map(function() {
return this.id;
}).get().join(',');
Upvotes: 1
Reputation: 79830
May coz be you are missing the );
in .each
$('td.play').each(function() {
notas.push(this.id)
});
var esArreglo = notas.join(',');
Upvotes: 0