Search code examples
javascriptzepto

Is there something like nextAll() in Zepto.js?


I have a list of nodes:

<div id="node-1"></div>
<div id="node-2" class="current"></div>
<div id="node-3"></div>
<div id="node-4"></div>
<div id="node-5"></div>

How can I with Zepto get all nodes 3-5, when using $(".current") as selector (node-2)?


Solution

  • Is there something like nextAll() in Zepto.js?

    Not according to the documentation, which has a notable gap after next and before not.

    This would suggest you'll need a loop, e.g.:

    var $current = $(".current"),
        $walk,
        $following = $(),
        $next;
    
    for ($walk = $current.next(); $walk[0]; $walk = $walk.next()) {
        $following.add($walk);
    }
    

    That use of add would work with jQuery. Zepto's docs claim that "APIs provided match their jQuery counterparts" (their boldface), but the add docs only talk about using a selector, so you may have to play with that a bit.