我想選擇表格第二行的所有行,我該怎麼做? 我試過下面的代碼,但它在Siebel OpenUI平臺上不適合我。從表格的第二行中選擇所有行?
$('#s_1_l').find("tr").each(function() {
if($(this).not(":first-child")){
alert($(this).find("td:eq(2)").text());
}
});
在此先感謝..
我想選擇表格第二行的所有行,我該怎麼做? 我試過下面的代碼,但它在Siebel OpenUI平臺上不適合我。從表格的第二行中選擇所有行?
$('#s_1_l').find("tr").each(function() {
if($(this).not(":first-child")){
alert($(this).find("td:eq(2)").text());
}
});
在此先感謝..
我的理解是,你要跳過第一<tr>
和選擇列#2和之後。
你可以做到這一點與nextAll()
方法:
CSS
tr{
padding:10px;
background-color:black;
}
jQuery的
// find the first <tr> in the table
// select all the following <tr>'s and make them yellow
$('table').find('tr').eq(0).nextAll('tr').css('background-color','yellow');
HTML
<table>
<tr><td>1</td></tr> <!-- not selected -->
<tr><td>2</td></tr> <!-- selected -->
<tr><td>3</td></tr> <!-- selected -->
<tr><td>4</td></tr> <!-- selected -->
<tr><td>5</td></tr> <!-- selected -->
<tr><td>6</td></tr> <!-- selected -->
<tr><td>7</td></tr> <!-- selected -->
</table>
非常感謝@ MonkeyZeus..IT正常工作。 – Chiranjit
歡迎您,如果它正確回答您的問題,請接受我的答案爲正確答案。 – MonkeyZeus
試試這個,我的好朋友:-)
$(document).ready(function(){
console.log($('table[id^=#s_1_l] tr').eq(1));
});
咦?第二行的所有行?你是指所有專欄? – BenM
你是否從第二行**開始** **單元**?你不能連續排成一行... – Joeytje50
@ Joeytje50不好與*那*態度=) – MonkeyZeus