In jQuery, you can use before and insertBefore to insert specified content before the specified element. There are differences in writing methods.
Let’s look at an example first:
In
Implementation:
$('
or
$('.div1').before('
Result :
Wrong writing:
$ ('
Result:
Not only will the element not be inserted in front of div1, but it will Delete div1
Summary:
Before is the element inserted in front of, followed by the inserted content element
insertBefore is preceded by the inserted content element, followed by which element Inserting
in front of an element cannot be reversed.
The above article briefly discusses the difference between jQuery before and insertBefore. This is all the content shared by the editor. I hope it can give you a reference, and I hope you will support the PHP Chinese website.
For more articles on the difference between jQuery before and insertBefore, please pay attention to the PHP Chinese website!