beginner beginner - 2 months ago 7
HTML Question

How to find next "p" sibling of "this" element using jquery?

We know we can use following syntax to select next element.

$("div + p")


It selects
<p>
element that are next to each
<div>
elements.
I want to select the next element using this.
for example
I tried

$("this + p") or
$(this + p")


But not working. Can anyone tell me correct syntax.

Answer

You can select next sibling of element using .next(). Use it like bottom example:

$(this).next("p")
Comments