jquery find vs children with contains

Benchmark created by Dan Manastireanu on


Preparation HTML

<div id="test">
<p>some text</p>
<p>some other text</p>
<p>nothing</p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
children p:contains
$('#test').children('p:contains("text")');
$('#test').children('p:contains("not found")');
ready
children :contains
$('#test').children(':contains("text")');
$('#test').children(':contains("not found")');
ready
find p:contains
$('#test').find('p:contains("text")');
$('#test').find('p:contains("not found")');
ready
find :contains
$('#test').find(':contains("text")');
$('#test').find(':contains("not found")');
ready

Revisions

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

  • Revision 1: published by Dan Manastireanu on
  • Revision 2: published on