jQuery :has vs .has() vs .parent() (v7)

Revision 7 of this benchmark created on


Description

Based on http://jsperf.com/jquery-has-vs-has

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>
<code>Foo bar<br>baz</code>
<code>Foo bar baz</code>

Test runner

Ready to run.

Testing in
TestOps/sec
:has selector
$('code:has(br)');
ready
.has() method
$('code').has('br');
ready
.parent()
$('code br').parent();
ready
.parents()
$('code br').parents();
ready

Revisions

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