In #9 press n, what does .next() function really do? How does it know where to go next?


#1

Please answer, thanks


#2

Hi Jhepong,

The jQuery next() function scans the HTML and looks for the next sibling of the current element in the HTML. So,

<div class="one"> <!-- current element -->
  <p>text...</p>
</div>
<div class="two"> <!-- this is .one's next sibling, so .next() == this <div> -->
  <p>text...</p>
</div>

There's not much to it :slightly_smiling:


.next()
#3

thanks.
how do you program if there is no more next sibling (like .next()=null) and you want to select back the very first sibling


#4

@jhepong This lesson teaches you how to do exactly that :slightly_smiling: Keep working through the exercises, and you'll see :slightly_smiling:


#5

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.