Speaking of the InsertBefore () method, in fact JavaScript and jquery have this method, then they use the same?
In fact, there is a little difference. Anyway, I love to confuse, make a small note first!
1. InsertBefore () method (JavaScript)
Grammar:
node. insertbefore (newnode,existingnode)//Both of these parameters are required
The InsertBefore () method inserts a new child node before the existing child node.
NewNode is a node object, which is the node you want to insert; Existingnode is also a node object that adds a child node before the new node.
For example:
2. InsertBefore () method (JQuery)
Grammar:
$ (content). InsertBefore (selector)
Note: If the method is used for an existing element, the elements are removed from the current position and then added to the selected element
For example: Insert a SPAN element before each P element
InsertBefore methods (JavaScript and jquery)