jQuery Create Element (v13)

Revision 13 of this benchmark created on


Preparation HTML

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

Teardown



            $('#target').html('');
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
div
var e = $('<div>').appendTo('#target');
ready
document.createElement
var e = $(document.createElement('div')).appendTo('#target');
ready
div with a closing tag
var e = $('<div></div>').appendTo('#target');
ready
self closing div
var e = $('<div/>').appendTo('#target');
ready
Best Way
var newDiv = $('<div/>');
newDiv.attr("id","myNewDiv").appendTo("#target");
ready

Revisions

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