作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我需要循环遍历 ID 为 #abc123 的 div 标签内的所有复选框
我该怎么做?
$("#abc123").foreach( ???? )
更新我的 html 行看起来像:
<tr>
<td><input .../> </td>
<td>234</td>
</tr>
我需要添加 <td>
的值进入复选框的 ID。
我会得到父级,然后以某种方式成为它的祖先吗?
最佳答案
$("#abc123 input[type=checkbox]").each(function()
{
});
更新:
好的,让我看看我是否弄清楚了。鉴于:
<tr>
<td><input .../> </td>
<td>234</td>
</tr>
你希望结果是(有效地)
<tr>
<td><input id="abc234" .../> </td>
<td>234</td>
</tr>
$("td input[type=checkbox]").each(function()
{
var id = $(this).next("td").text();
$(this).attr("id", "abc"+ id);
});
关于javascript - 遍历 div 标签内的所有复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3532640/
我是一名优秀的程序员,十分优秀!