javascript - 使用 find 在容器内进行 jQuery 搜索失去了对 jQuery 的控制

标签 javascript jquery html

我需要在特定行的table内的input中查找信息。

我有这个

var myElements = $('#myTable tbody').find('tr');
console.log(myElements);

这会正确显示表格中的项目

[tr.rowcenter, tr.rowcenter, prevObject: e.fn.e.init[1], context: document, selector: "#myTable tbody tr", constructor: function, init: function…]
0: tr.rowcenter               <- OK
1: tr.rowcenter               <- OK
context: document
length: 2
prevObject: e.fn.e.init[1]
selector: "#tRangos tbody tr"
__proto__: e[0]

在本例中只有 2 行

但是当我想连续查看时,就像这样

myElements[i].find(".r_min").val(); //inside have .r_min , .r_max and .r_val

我明白了

Uncaught TypeError: myElements[i].find is not a function

console.log(myElements[i]) 只看到 HTML 元素时

<tr class="rowcenter">
    <td>
        <input class="r_min" value="10.0">
    </td>
    <td>
        <input class="r_max" value="12.0">
    </td>
    <td>
        <input class="r_val" value="50.00">
    </td>
    <td> other trash</td>
</tr>

为什么?

注意我使用 jQuery 1.7.2

最佳答案

使用myElements.eq(i)而不是myElements[i]。这将过滤掉除第 i 行之外的所有行。

关于javascript - 使用 find 在容器内进行 jQuery 搜索失去了对 jQuery 的控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30142655/

相关文章:

jquery - validationengine插件的错误提示位置问题(Position Absolute)

javascript - 使用jquery向表添加行

javascript - IE10 和 11,jQuery 动画和溢出的意外行为

html - 宽度 100% 未使用全屏

javascript - JQuery,找出可见的内容并将其隐藏

基于域的 Javascript 引荐来源网址检查

javascript - 如何将html标签放入文本节点

javascript - 单击子内部 anchor 元素时如何删除父div?

ios - 在 native iOS 应用程序中启用自动播放

javascript - 当鼠标悬停在上面时,如何阻止 mouseOver 文本闪烁