jQuery Selectors

Benchmark created by Nilayan Sharma on


Description

Compare jQuery selectors for a single element

Preparation HTML

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

<div id="top">
  <p id="para_1" class="mytext">Paragraph one</p>
  <p id="para_2" class="mytext">Paragraph two</p>
  <p id="para_3" class="mytext">Paragraph three</p>
  <span id="span_1" class="mytext">Text in a span</span>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
Class + Filter
jQuery('.mytext').eq(3);
ready
ID
jQuery('#span_1');
ready
getElementById
var el = document.getElementById("span_1");
$(el);
ready

Revisions

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

  • Revision 1: published by Nilayan Sharma on