Change Class Attribute

Benchmark created on


Preparation HTML

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

<div class="foo"><\div>

Setup

var div = $('div.foo');

Test runner

Ready to run.

Testing in
TestOps/sec
removeClass() then addClass()
div.removeClass('foo');
div.addClass('bar');
ready
.attr()
div.attr('class', 'bar');
ready

Revisions

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