Javascript – Inserting HTML into a div


I am trying to insert a chunk of HTML into a div. I want to see if plain JavaScript way is faster than using jQuery. Unfortunately, I forgot how to do it the 'old' way. 😛

var test2 = function(){
    var cb = function(html){
        var t1 = document.getElementById("test2");
        var d = document.createElement("div"); ="oiio";
        d.innerHtml = html;
        console.timeEnd("load data with javascript");
    console.time("load data with javascript");
    $.get("test1.html", cb);

what am i doing wrong here guys?

Someone asked which is faster, jquery or plain js so i wrote up a test:

plain js is 10% faster

Best Solution

I think this is what you want:

document.getElementById('tag-id').innerHTML = '<ol><li>html data</li></ol>';

Keep in mind that innerHTML is not accessible for all types of tags when using IE. (table elements for example)