jQuery :contains()

JavaScript performance comparison

Test case created by

Preparation code

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

<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn</div>
    

Preparation code output

<div>John Resig</div> <div>George Martin</div> <div>Malcom John Sinclair</div> <div>J. Ohn</div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Raw DOM
var all = [].slice.call(document.getElementsByTagName("div"));
all.forEach(function(elem) {
   if (elem.innerHTML.indexOf("John") != -1)
      elem.style.textDecoration = "underline";
});
pending…
jQuery :contains()
$("div:contains('John')").css("text-decoration", "underline");
pending…

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

Compare results of other browsers

0 Comments

John Resig
George Martin
Malcom John Sinclair
J. Ohn