簡體   English   中英

使用jquery從html表中選擇第二行

[英]select the second row from the html table using jquery

我使用以下jQuery函數突出顯示Html表中的行(使用bg color)。它工作正常。我的問題是如何從表中選擇第二行.``highlight''是一個類

.highlight td {
  background: #E7EFFA;
}

$('#Tabnameabcd tr').mouseover(function() {
  if ($.trim($(this).text()) != '')
    $(this).addClass('highlight');
}).mouseout(function() {
  $(this).removeClass('highlight');
});

which means:

name    age    depart

test    12     test
test1   13     tested

這里的姓名,年齡作為第一行出發 。即標題。 下一個測試test1是tabe的元素。如果我使用那個jquery函數,則title(name,age,depart)適用。 我只需要將該jquery函數應用於表的元素而不是標題 ?該怎么做?

要獲取第二行: $('#Tabnameabcd tr').eq(1)$('#Tabnameabcd tr:eq(1)')

要從第二個開始獲取所有行(演示: http : //jsfiddle.net/pXj5F/ ):

$('#Tabnameabcd :nth-child(n+2)')

您還應該考慮theadtbody ...

這樣嘗試

$('#mytable_id tr').eq(1).(your function here);

而您想申請的行不是傾斜,那么您也可以使用

$("#mytable_id td").function({
      //Play here
});

它將適用於表中除標題以外的所有td。您也可以使用此功能的“ .not()”函數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM