jQuery parent/child selectors (v98)

Revision 98 of this benchmark created by PW on


Description

The different ways to select (context, pure selector, +find()) DOM elements using jQuery in parent/child scenarios.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div>
  <ul id="list">
    <li class="test">
    </li>
    <li>
    </li>
    <li class="test">
    </li>
    <li class="test">
    </li>
    <li>
    </li>
    <li class="test">
    </li>
    <li>
    </li>
    <li class="test">
    </li>
    <li>
    </li>
    <li class="test">
    </li>
  </ul>
</div>
<div class="test">
</div>
<script>
  var list = document.getElementById('list');
</script>

Setup

var $list = $(list);

Test runner

Ready to run.

Testing in
TestOps/sec
cached context
var $test = $('.test', $list);
ready
cached context and find()
var $test = $list.find('.test');
ready
cached immediate children
$test = $list.children('.test');
ready

Revisions

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