在表中搜索innerHTML值 [英] search for innerHTML value in a table

查看:82
本文介绍了在表中搜索innerHTML值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在表中搜索具有特定innerHTML值的行?

how can I search in a table for a row with a specifik innerHTML value?

<table>
<tr><td>test</td><td>100</td></tr>
<tr><td>test</td><td>200</td></tr>
<tr><td>test</td><td>300</td></tr>
</table>

我需要第二个td为200的行(tr)的索引

I need the index for the row (tr) where the second td is 200

此处索引必须为1

$('table tr'). something??

并且我还需要一个版本,以便在给定值大于(asc)大于200(如果存在)之前选择索引

and I also need a version that select the index before a give value is bigger (asc) than 200 (if it exists)

推荐答案

$("TABLE TR").each(function() {
    if ($("TD", this).eq(1).html()== "200") {
        // Your logic here

        return false; // break out of .each() loop
    }
});

这篇关于在表中搜索innerHTML值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆