Check if div exists (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="b" class="a"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
Property Lookup
$(".a")[0]
ready
.length
$(".a").length
ready
.hasClass()
$('div').hasClass('a')
ready
.size()
$(".a").size()
ready
If id not null
$('#b').attr('id') != null
ready
If class not null
$('.a').attr('class') != null
ready
Id length
$("#b").length
ready

Revisions

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