如何获取<td>从& lt; tr>在jQuery
how to get the id attribute of <td> from <tr> in jQuery?
请帮帮我。
而不是循环…我们是否有像get第一个td或第二个td的id这样的东西?
示例:
"<tr class='test_point' id="+fileName+"><td><img src='"+ROOT_PATH+"/assets/diamond.png' /><td class='test_point_name' id="+test_point_id+">"+test_point
+"</td></tr>"
在这里通过ID获取tr
$(#fileName).each(function( index ){
console.log( index + ": " + $(this).text() );
//console.log("id_value: "+$(this).attr('id'));
console.log("test_value: "+ $(this).find('td').attr('id'))
}
通过索引获取项目的id
,使用此。
$('#fileName').find('td')[0].id;
其中[0]
表示第一,[1]
表示第二…等等
您的each
语句选择器有点偏离。你缺少引号:
$("#fileName").each(function( index ){
或者您想使用变量fileName
$("#" + fileName).each(function( index ){
在任何情况下,ID应该是唯一的。我猜你想使用你的tr
s类:
$(".test_point").each(function( index ){
$('#your-tr-id-here').each(function() {
$(this).children('td').each(function() {
console.log('td ID: ' + $(this).attr('id'));
});
});
相关文章:
- 通过点击<李>在jQuery中
- 如何逃离<脚本>jquery html()中的标记.我使用了innerHTML和outerHTML来解决这个
- 有没有一种方法可以检测ios<>使用jquery和触发器操作形成导航按钮
- Jquery在点击<a>标签
- 将jQuery从1.8更新到1.11<a>标记未附加
- 转换<a>使用jQuery将文本字符串转换为dom元素
- 在<头部>使用javascript/jQuery
- jQuery只隐藏<tr>在一张桌子上
- jQuery可读性:在<李>要素
- jquery仅限<并且>文本框中的符号
- 检查页面范围并提取<h1>内容(如果使用JQuery存在页面)
- 检测活动<李>用于jQuery转盘(分页)
- jQuery:如何添加<br/>在不同的字符串中换行以分隔2中的句子
- Jquery将css类添加到父级<ul>元素
- jQuery对嵌套在<李>并且<a>元素,同时离开父<ul>打开
- 返回List<字符串>Jquery中的from JSON调用具有未定义的长度
- 将html注入<李>使用js或jquery
- <script src=“//代码.jquery.com/jquery-1.11.1.min.js”></
- 如何将复杂对象从jquery传递到标签<a>
- 带有lt jQuery的变量