Reputation: 71208
<table id ='t1'>
<tr val='1'></tr>
<tr val='2'></tr>
<tr val='3'></tr>
<tr val='4'></tr>
<table>
how to get from this an array = 1,2,3,4
Upvotes: 3
Views: 939
Reputation: 41232
This should work:
$.map( $( "table#t1 tr"), function( item) { return $(item).attr("val");})
Upvotes: 0
Reputation: 630409
You can use .map()
, like this:
var arr = $("#t1 tr").map(function() { return $(this).attr("val"); }).get();
Upvotes: 7