jquery select next tag, but not of the same type
If I have this structure:
<h5>Some Text</h5>
<div>Some more text related to the text above.</div>
I know I can select the div with:
$('h5 + div')
My problem is if I have a jquery Object already containing the h5 tag, is there a way to access that following div?
$('h5').each(function() {
// now how do I grab the div just below it?
开发者_高级运维 $DIV = ??????????
}
$.next()
only apparently finds actual siblings (the tags must be the same) so its not any help here.
The documentation made it look like .next only got tags of the same type, and when I tested I made a different error, so this question is really a non-question :-\
Just use this, you can specify the selector while using next
so it will look for that in the siblings.
$('h5').next("div");
Looking at your markup, next()
will also help you since div
is the immediate sibling of h5
.
精彩评论