parents.find vs parents().parents()

JavaScript performance comparison

Test case created

Preparation code

<div class="control-group">
        <div class="controls radio-other">
                 <label class="radio"><input type="radio" name="enq002" id="enq002" value="enq002-opt">Ja</label>
         <label class="radio"><input type="radio" name="enq002" id="enq003" value="enq003-opt">Nee</label>
         <label class="radio"><input type="radio" name="enq002" id="enq004" value="enq004-opt" data-linktype="toggle" data-target="#enq005"> Anders, namelijk...</label>
                                 <input type="text" placeholder="Alternatief antwoord" id="enq005" class="hide other">

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

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Parent().parent().find()
$('input[type="radio"]').parent().parent().find('.other').toggleClass('hide');
 
pending…
parents.find()
$('input[type="radio"]').parents().find('.other').toggleClass('hide');
 
pending…
Parents('elemtent').find()
$('input[type="radio"]').parents('.radio-other').find('.other').toggleClass('hide');
 
pending…
parentsUntil('emelemt').find()
$('input[type="radio"]').parentsUntil('.radio-other').find('.other').toggleClass('hide');
pending…
parents('element').closest()
$('input[type="radio"]').parents('.radio-other').closest('.other').toggleClass('hide');
pending…
parentsUntil('element').closest()
$('input[type="radio"]').parentsUntil('.radio-other').closest('.other').toggleClass('hide');
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment