Jquery show hide toggle

Benchmark created by Eonasdan on


Description

test the differences between jquery's different methods to show/hide an element

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style>
.hide {display:none;}
</style>

<div class="foo"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
toggle()
$('#foo').toggle();
$('#foo').toggle();
ready
show() hide()
$('#foo').hide();
$('#foo').show();
ready
.addClass() & .removeClass()
$('#foo').addClass('hide');
$('#foo').removeClass('hide');
ready
.css({})
$('#foo').css({'display':'none'})
$('#foo').css({'display':'block'});
ready

Revisions

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

  • Revision 1: published by Eonasdan on