jQuery next vs siblings (v3)

Revision 3 of this benchmark created on


Description

jQuery's next/prev vs using the slibings('selector')

NOTE THE CHANGE THAT HAS MULTIPLE MATCHING SIBLING CLASSES. Does next() do the same thing as .siblings()?

Preparation HTML

<div id="parent">
  <div class="sibling"></div>
        <div class="child"></div>
  <div class="andThisWillReallyMessUpTheTest"></div>
        <div class="sibling"></div>
  <div class="sibling"></div>
</div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

Setup

var child = $('#parent').find('.child');

Test runner

Ready to run.

Testing in
TestOps/sec
next
var next = child.next('.sibling');
console.log(next.length);
ready
siblings
var sibling = child.siblings('.sibling');
console.log(sibling.length);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.