jQuery Parent() vs Closest() (v2)

Revision 2 of this benchmark created on


Preparation HTML

<ul>
<li><span><a id="x1"></span></li>
<li><span><a id="x2"></span></li>
<li><span><a id="x3"></span></li>
<li><span><a id="x4"></span></li>
</ul>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
Parent
$('a:eq(1)').parent().parent();
ready
Closest
$('a:eq(1)').closest('li');
ready
Parent(li)
$('a:eq(1)').parent('li');
ready

Revisions

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