jQuery Parent() vs Closest()

Benchmark created by Frank Parent on


Preparation HTML

<ul>
<li><a id="x1"></li>
<li><a id="x2"></li>
<li><a id="x3"></li>
<li><a id="x4"></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('li');
ready
Closest
$('a:eq(1)').closest('li');
ready

Revisions

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