Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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 - Fatal编程技术网

jquery选择下一个标记,但不是同一类型

jquery选择下一个标记,但不是同一类型,jquery,Jquery,如果我有这种结构: <h5>Some Text</h5> <div>Some more text related to the text above.</div> 我的问题是,如果我有一个jquery对象已经包含h5标记,有没有办法访问下面的div $('h5').each(function() { // now how do I grab the div just below it? $DIV = ?????????? } $

如果我有这种结构:

<h5>Some Text</h5>
<div>Some more text related to the text above.</div>
我的问题是,如果我有一个jquery对象已经包含h5标记,有没有办法访问下面的div

$('h5').each(function() {
    // now how do I grab the div just below it?
    $DIV = ??????????
}
$.next()
显然只找到实际的同级(标记必须相同),因此这里没有任何帮助


文档让它看起来像。next只得到了相同类型的标签,当我测试时,我犯了一个不同的错误,所以这个问题实际上是一个非问题:-\

使用这个,你可以在使用
next
时指定选择器,这样它会在同级中查找它

$('h5').next("div");
查看您的标记,
next()
也将对您有所帮助,因为
div
h5
的近亲

$('h5').next("div");