日期:2014-05-16  浏览次数:20321 次

jquery 创建dom 用的是createElement还是innerHTML?
最近分析了一下js里面innerHTML 和 createElement方式创建dom的效率,与浏览器有关,但总的来说innerHTML更优越一些。
不过我始终没搞清楚jquery到底是用哪种方式把html构造成dom的
eg:$("<div><table></tr..........</div>")

jquery的源码不太好分析,哪位高人能指点一下?

------解决方案--------------------
引用If the HTML is more complex than a single tag without attributes, as it is in the above example, the actual creation of the elements is handled by the browser's innerHTML mechanism. In most cases, jQuery creates a new <div> element and sets the innerHTML property of the element to the HTML snippet that was passed in. When the parameter has a single tag, such as $('<img />') or $('<a></a>'), jQuery creates the element using the native JavaScript createElement() function.