我需要一種只調用一行文本的算法。jQuery在表格中找到文本
我的td包含數字和文本,我只想在我的「td」文本。
演示:http://jsfiddle.net/3yYFY/1
例如:
在第二行 = accure,鱷魚,獾
在第三行 =斑馬,大象
有很多行(td)我的表和文字不位於一個特定的列
HTML:
<table id="docsTable">
<tr bgcolor="#E7DDCC" class="liste-0">
<td align="center"><input type="checkbox"/></td>
<td>Document Title 1</td>
<td>567</td>
</tr>
<tr bgcolor="#E7DDCC">
<td align="center"><input type="checkbox"/></td>
<td>accure</td>
<td>134</td>
<td>alligator</td>
<td>badger</td>
</tr>
<tr bgcolor="#E7DDCC">
<td align="center"><input type="checkbox"/></td>
<td>Zebra</td>
<td>231</td>
<td>Elephant</td>
</tr>
</table>
<input type='button' id='btnTest' value='Get Rows' />
的jQuery:
$(function() {
$('#btnTest').click(function() {
var arr = $('#docsTable tr').has('input[type="checkbox"]:checked').map(function() {
alert($('td:eq(1)', this).text())
});
});
});
alert($(this).text())將返回每行的文本。這是你在找什麼? –
我只需要連續的所有字母, 爲第二行中的一個例子:accure,鱷魚,獾 – aldimeola1122