There is a key element in jquery that operates the same way, but renders different results.
<!DOCTYPE HTML><HTMLLang= "en"> <Head> <MetaCharSet= "Utf-8"> <title>Test</title> <Scriptsrc= "Jquery.js"></Script> </Head> <style>P{Background-color:Aquamarine; } </style> <Body> <PID= "N1"> <spanID= "N2">Span#n2</span>N1</P> <PID= "N3"> <labelID= "N4"class= "Move">Label#n4</label>N3</P> <PID= "N5"> <spanID= "N6">Span#n6</span>N5</P> <PID= "N7"> <spanID= "N8">Span#n8</span>N7</P> <PID= "N9"> <spanID= "N10">Span#n10</span>N9</P> <PID= "N11"> <spanID= "N12">Span#n12</span>N11</P> </Body></HTML>
Create a new jquery div object first:
Let Newdiv = $ (' <div>new one</div> ');
Use the following statements, respectively, to see what works.
$ (' #n1 '). Append (Newdiv.clone ()); Newdiv.clone (). InsertAfter (' #n1 '); Newdiv.clone (). AppendTo (' # N3 '); $ (' #n5 '). Prepend (Newdiv.clone ()); $ (' #n5 '). InsertBefore (Newdiv.clone ()); Newdiv.clone (). Prependto (' #n7 ') $ (' #n9 '). Before (Newdiv.clone ()); Newdiv.clone (). Before (' #n9 '); $ ( ' #n11 '). After (Newdiv.clone ()), Newdiv.clone (). After (' #n11 ');
Believe that after the above code you can know some relationships:
1 to and without to is an opposite relationship
2 **pend is added at the end of the P element and becomes P's last-child insert** is added outside the P element, becomes the next of P, or first-sibling
3 A.before (b) = B.insertbefore (a) a.after (b) = B.insertafter (a) The effect is equal, but the return value is not the same, if the use of before returns a, if insert returns a B
Hope that the above summary can be helpful to your understanding.
The difference between append appendTo prepend prependto insertbefore InsertAfter after before in jquery