2010-05-24 117 views
3

我正在尋找在表格第二行選擇列2-4。 jquery是否在其選擇器中具有任何「和」功能?或者我會不得不這樣做?用jquery選擇特定範圍的列

$('#id tr:eq(1)').find('td:lt(5)').find('td:gt(1)') 

回答

3

我還沒有試過,但理論上它應該工作:

$('#id tr:eq(1) td:lt(5):gt(1)') 
3

.slice()作品以及

$('#tableId tr').eq(1).find('td').slice(1,4); //2nd row, 2nd-4th td 

$('#tableId tr').slice(1,5); // get specific rows 

$('#tableId td').slice(1,4) // get specific columns 

$('#tableId tr').each(function() { 
    // do code per row 
    var $columnRange = $(this).find('td').splice(1,4); 
});