Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取jQuery元素的第二个子元素_Jquery_Html_This_Element - Fatal编程技术网

获取jQuery元素的第二个子元素

获取jQuery元素的第二个子元素,jquery,html,this,element,Jquery,Html,This,Element,这个问题可能会重复,但我没有发现任何有用的东西 以下是我的片段: $(“表tbody tr”)。悬停( 函数(){ var secondCell=$(this).children[1].textContent; //secondCell.someCode }, 函数(){ //一些代码 } ); 福 福 福 酒吧 酒吧 酒吧 在jquery中,.children()是一个函数。因此,在从数组中获取元素之前,需要调用它。请看一下文档 您可以这样使用:。有几种方法: $(“第n个孩子(2)”)

这个问题可能会重复,但我没有发现任何有用的东西

以下是我的片段:

$(“表tbody tr”)。悬停(
函数(){
var secondCell=$(this).children[1].textContent;
//secondCell.someCode
},
函数(){
//一些代码
}
);

福
福
福
酒吧
酒吧
酒吧
在jquery中,
.children()
是一个函数。因此,在从数组中获取元素之前,需要调用它。请看一下文档


您可以这样使用:。

有几种方法:

$(“第n个孩子(2)”)

$(“tr”).children().eq(1)

$(“tr td”).eq(1)


$(“tr td”).filter(“:n个子(2)”)
您也可以使用以下代码

$("table tbody tr").hover(

    function() {
        var secondCell = $(this).find("td:eq(1)").text();

        //secondCell.someCode
    },

    function() {
        //some code
    }

);

$(“tr td:nth child(2)”)应该可以了。谢谢你,哈比比,但是你知道,我想用$(this)获取已经选中的行的单元格,无论如何,谢谢。哦,是的,我看到了这个,但是当我键入它时,我的IDE说
children
不是函数,而是数组,但是当我尝试它时,它工作了。