More information on the logic of this new "next()" method please?


So, I have all my code correct but I just like to know the background logic/rules to everything. I need more information on what this new next() method actually does?

Does it mean that it will just magically search for all other divs which share the same class of "article" and automatically add this specified class of "current" to that following one in the html hierarchy? If so, how does it know to look for an "article" div it is not being told that anywhere? How does it know not to put it inside the children? If there had been another div between articles would it just add it to that?

I'm sorry but sounds to easy to be true, I wonder all of its applications or if it is built specifically for this scenario only?


  <li class="active">third</li>

The selector,

var kids = $('ul').children()

returns a collection of list item nodes. They are all direct children of the UL, and consequently they are siblings.

var active = $('.active')
var pre = active.prev().text()
var post =

console.log(pre) // second

console.log(post) // fourth


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