jQuery has vs * (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul>
    <li>
        <a href="#">Link 1</a>
        <ul>
            <li><a href="">Sub link</a></li>
        </ul>
    </li>
    <li>
        <a href="">Link 2</a>
        <ul>
            <li><a href="">Sub link</a></li>
        </ul>
    </li>
</ul>

Test runner

Ready to run.

Testing in
TestOps/sec
$('li').has('ul')
$("li").has("ul").children("a").addClass("something");
ready
$('li ul')
$('li ul').parents('li').children('a').addClass('something');
ready

Revisions

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