jQuery child selectors (v64)

Revision 64 of this benchmark created by Christiaan Rakowski on


Description

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

Preparation HTML

<script src="https://code.jquery.com/jquery-2.0.3.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 = $('#list');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
selector
var $test = $('#list > .test');
 
ready
find children
var $test = $list.find('> .test')
ready
children
var $test = $list.children('.test');
ready
Created Context
var test = $('.test', $list);
ready
children with separate filter
var $test = $list.children().filter('.test');
ready

Revisions

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