Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the very next node with jQuery

Tags:

jquery

dom

I'm sure it's pretty easy, but I just can get it to work.

I have the following structure:

<div class="row forWidget"></div>
<div class="droppable"></div>

I have the first element in my jQuery object.

$widget = $('div.row');

And I want to .find() the element div.droppable from there.

How do I achieve this? I thought it would be .next(), but it seems to only match real siblings.

like image 754
Johannes Klauß Avatar asked Feb 14 '26 04:02

Johannes Klauß


1 Answers

You serach for the .next()

var next = $('div.row').next();

http://api.jquery.com/next/

From jQuery site

Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.

like image 78
Simon Edström Avatar answered Feb 15 '26 18:02

Simon Edström



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!