jquery read table

$('#mytable tr').each(function() {
    var customerId = $(this).find("td").eq(2).html();    
});


var items=[], options=[];

//Iterate all td's in second column
$('#tableId>tbody>tr>td:nth-child(2)').each( function(){
   //add item to array
   items.push( $(this).text() );       
});

//restrict array to unique items
var items = $.unique( items );

//iterate unique array and build array of select options
$.each( items, function(i, item){
    options.push('<option value="' + item + '">' + item + '</option>');
})

//finally empty the select and append the items from the array
$('#selectId').empty().append( options.join() );

你可能感兴趣的:(jquery)