用jQuery编写$($(this).children()[1]).html()的更紧凑/可读的方式
16lz
2021-01-22
I often find myself doing things like this when manipulating tables:-
我经常发现我自己做这样的事情当操作表格:-
$($('table tr').children()[2]).html();
For when I want the cell in the 3rd column as a jQuery wrapped set. Selecting the node using [n]
and then passing to $()
to get a jQuery wrapped set.
当我想要第三列中的单元格作为jQuery封装集时,使用[n]选择节点,然后传递到$()获取jQuery封装集。
Is there a neater more readable way to do this?
有没有一种更整洁、更容易读懂的方法呢?
1 个解决方案
#1
7
Use the .eq()
method
使用.eq()方法
$('table tr').children().eq(2).html();
you could alternatively use the :eq
selector
您也可以使用:eq选择器
$('table tr > :eq(2)').html();
更多相关文章
- jQuery $ajax 传中文数据到action乱码解决方法
- JQuery 的选取元素 和 方法
- jquery的function方法中each循环里面判断失败跳出function方法
- jQuery.zTree 点击节点展开折叠子节点
- js/jquery常用方法------复制粘贴至剪切板
- Jquery ready和window.onload方法区别
- jQuery -> 获取后代元素的三种方法
- jquery手指触摸滑动放大图片的方法(比较靠谱的方法)
- jquery 阻止表单提交方法