2014-02-28 33 views

回答

3

你可以嘗試

$(table).find('td:first').text() //can you table id or class 

可以在一個循環遍歷所有行獲得第一個單元格值

var array = new Array(); 

$('table tr').each(function() { 
    var firstCell = $(this).find('td').first(); 
    array.push($firstCell.text()); 
}); 
1
var array = []; 

jQuery('table tr').each(function() { 
    var $row = $(this); 
    var $firstCell = $row.find('td:first'); 
    array.push($firstCell.text()); 
}); 
0

嘗試:

var a = new Array(); 

$("table:eq(5) tr td:first-child").each(
    function(){ 
     a.push($(this).text()) 
    }); 
0

可以遍歷所有的表格都是這樣的:

$("#tableId > tbody > tr").each(function(){ 
    var name = $(this).find("td:first").text(); 
    console.log("Method name: "+name); 
}); 

您可以全局初始化一個數組並保存在循環中的數組中。希望這可以幫助。

相關問題