InsertBefore (): A.insertbefore (b)
A in front, b in the back,
A: is a selector, B: is also a selector
Get:
InsertAfter (): With InsertBefore () is the same reason
A.insertafter (b)
A in the back, B in the front
Now it's said before ()
Before (): A.before ()
A is an existing selector on the page, B is what you need to add, note: What is what, will identify the label, B is not a selector
A in the back, B in the front
Finally get:
Do you see that? P1 does not recognize the selector, it is a string directly before the. P2 Selector
After (): With before () is the same, just one in the previous
I just want to say InsertBefore (), InsertAfter () and before (), after () the difference, I feel the biggest difference is to see the scene you want to use, if you need two of the selector position to swap
InsertBefore (), InsertAfter ()
If you need a selector with a text exchange position can be used before (), after (); Of course, it's not just a replacement.
The replacement position is that there is already something on the page, this method can also add to the page does not have things, such as:
$ (' <p class= ' p3 ' > Hehe </p> '). InsertBefore ('. P1 ');
The above mentioned is small set to introduce the jquery in the InsertBefore (), InsertAfter (), after (), before () difference introduction, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!