The creation of innerHTML is a very efficient interface for nodes. jquery uses innerHTML on node operations, creating efficiencies that are at least 2-10 times faster than createelement, and can generate a bunch of nodes at a single point, but there are some compatibility issues.
I have summed up the following points, of course, compatible with the jquery solution as well.
IE will be the user string Trimleft operation, the user may be the intention is to need a blank IE8 some elements innerHTML is read-only IE will ignore the beginning of the scope of the element does not execute script scripts, of course, if support defer IE9 before the bangs Besides, some labels cannot be used as child elements of a div, such as TR,TB, col, etc.
The node operations of jquery ultimately need to be translated into document fragmentation, which is done through the Buildfragment () method, so innerHTML compatible fixes are also naturally in buildfragment methods. We figure out why and then analyze it, but the whole code is simple.
1: First no scope problem, through the document fragment to create a div containing container, so that all elements are included in the DIV element, including Script,style, and other elements of the domain, a good solution to the TMP = TMP fragment.appendchild ( Context.createelement ("div")); tmp.innerhtml = Elem
2: For the element that does not support the innerHTML attribute, give it separately, through the regular extraction to this node name to deal with Wrapmap = {tr: [2, <table><tbody>, "</tbody></t Able> "],} tag =/< ([\w:]+)/.exec (' <tr> Resource Network </tr> ') wrap = Wrapmap[tag] Wrapmap._default; tmp.innerhtml = wrap[1] + elem.replace (rxhtmltag, "<$1></$2>") + wrap[2]; If you encounter a label for wrapmap[' tr ', it automatically wraps a layer of nodes, which is supported.