hasClass vs native (v11)

Revision 11 of this benchmark created by is Vs HasClass on


Description

Test jQuery.hasClass vs native

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var et = $("#test")[0];
</script>
<div id="test" class="my-test"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
hasClass()
$('#test').hasClass("my-test")
ready
native
et.className.match(/my-test/)
ready
addClass
$('#test').addClass("selected")
ready
native 2
$j('#test')[0].className = "selected"
ready

Revisions

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