jQuery: element operation (add, delete)

1、append()

Used to add content at the end of the selected element (still inside the element)

2、prepend()

Used to insert content at the beginning of the selected element (still inside the element)

3、after() 和 before()

The after() method inserts content after the selected element.
The before() method inserts content before the selected element.

4、remove() 和 empty()

remove(): delete the selected element (and its child elements)
empty(): delete the child element from the selected element

empty() only deletes the text of the element, occupying the position, and is not displayed on the page, but the DOM node is not deleted.
remove() deletes the entire dom node and does not occupy the position

Guess you like

Origin blog.csdn.net/qq_41504815/article/details/114645579