jQuery Parents vs Closest (v5)

Revision 5 of this benchmark created on


Description

Similar to parent vs closest, only this time testing when searching >1 level of the DOM ancestors.

Preparation HTML

<div class="panel" id="step_1" rel="vehicle_1">
                            <h3>Model Year</h3>
                            
                                <div class="panel_content">
                                    <table id="model_year">
                                        <tbody>
                                            <tr>
                                                <td>
                                                    <a href="#1">2012</a>
                                                    <a href="#">2011</a>
                                                    <a href="#">2010</a>
                                                    <a href="#">2009</a>
                                                    <a href="#">2008</a>
                                                    <a href="#">2007</a>
                                                    <a href="#">2006</a>
                                                    <a href="#">2005</a>
                                                </td>
                                                <td>
                                                    <a href="#">2004</a>
                                                    <a href="#">2003</a>
                                                    <a href="#">2002</a>
                                                    <a href="#">2001</a>
                                                    <a href="#">2000</a>
                                                    <a href="#">1999</a>
                                                    <a href="#">1998</a>
                                                    <a href="#">1997</a>
                                                </td>
                                                <td>
                                                    <a href="#">1996</a>
                                                    <a href="#">1995</a>
                                                    <a href="#">1994</a>
                                                    <a href="#">1993</a>
                                                    <a href="#">1992</a>
                                                    <a href="#">1991</a>
                                                    <a href="#">1990</a>
                                                    <a href="#">1989</a>
                                                </td>
                                                <td>
                                                    <a href="#">1988</a>
                                                    <a href="#">1987</a>
                                                    <a href="#">1986</a>
                                                    <a href="#">1985</a>
                                                    <a href="#">1984</a>
                                                    <a href="#">1983</a>
                                                    <a href="#">1982</a>
                                                    <a href="#">1981</a>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                </div> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Parents
$(this).closest(".panel").attr('id');
 
ready
Closest
$(this).closest(".panel").attr('id');
ready

Revisions

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