Core BuildfragmentDom native interfaces are simple and unitary, parameter types are determined, and not overloaded, and only one element is processed at a time. In the view of jquery completely opposite parameters are complex and diverse, interface overload is severe. If you pass more than one node element at a time, you must introduce document fragmentation in order to optimize processing. We know that using document fragmentation is nothing more than creating first: Fragment = Context.createdocumentfragment () and then put all the DOM nodes that need to be processed into AppendChild: Buildfragment for document fragmentation creation , you can see that the 2 parts have been cut: First look at the first part of the code to collect node elements:
This code contains six different types of parameters, basically covering all the buildfragment processing is actually very simple, we only need to decompose the different types of parameters, the indentation into the document fragment, of course, because the type of different ways of processing.
- var $newdiv 1 = $ (' <div id= "Object1"/> '),
- Newdiv2 = document.createelement (' div '),
- Existingdiv1 = document.getElementById (' foo ');
- $ (' body '). Append ($newdiv 1, [Newdiv2, Existingdiv1, ' <td> resource net </td> ', ' text ', ' <script>alert (1) '])