hasClass (v22)

Revision 22 of this benchmark created by sefasefseaf on


Preparation HTML

<span class="class1, class2">Test</span>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
length
if ($('span.class1.class2').length) {
console.log('length')
}
ready
hasclass
if ($('span').hasClass('class1') && $('span').hasClass('class2')){
console.log('hasClass')
}
ready
is
if ($('span').is('.class1, .class2')){
console.log('is')
}
ready

Revisions

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