3
我有一个文本。现在我想如果我的文本与任何列值匹配,那么我的方法返回该行和列号。我目前的代码只读取列号,但我不知道如何获得行号。获得当前行号列号
样品表:
var index = $('tr td').filter(function() {
return $(this).text() == 'Dhaka';
}).index();
console.log(index);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<td>Rion</td>
<td>Bogra</td>
<td>34</td>
</tr>
<tr>
<td>Hasib</td>
<td>Dhaka</td>
<td>23</td>
</tr>
</table>
如果我给“达卡”作为我给出的文本,然后我的代码返回第1列,但我也需要排数为2
在表(3,2),我如何获得第3列和第2行的值? –
(0,0)(row,column)could not found.it's show(-1,-1).how I解决它? –
@golammoktadir由于索引从0开始,因此'Rion'打印为(0,0),并且此表中没有(3,2)。 – kukkuz