jQuery has vs *

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul>
    <li><a href="#">parent</a></li>
    <li><a href="#">parent</a>
    <ul>
        <li>child</li>
        <li>child</li>
    </ul>
</ul>

Test runner

Ready to run.

Testing in
TestOps/sec
:has()
$('li:has(ul)').addClass('test-class');
ready
*
$('li > *').parent().addClass('test-class')
ready
has(*)
$('li').has('*').addClass('test-class');
ready
:has(*)
$('li:has(*)').addClass('test-class');
ready

Revisions

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