Home>Article>Web Front-end> How to delete html elements with jquery
Delete method: 1. Use the remove() method to delete the selected element and its sub-elements, the syntax "$(selector).remove()"; 2. Use the empty() method to delete the selected element and its sub-elements from the selected element. To delete child elements from a selected element, the syntax is "$(selector).empty()".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
If you need to delete elements and content, you can generally use the following two jQuery methods:
remove() - delete the selected element (and its sub-elements)
empty() - Removes child elements from the selected element
jQuery remove() method
jQuery remove() method removes the selected element and its child elements.
这是 div 中的一些文本。这是在 div 中的一个段落。
这是在 div 中的另外一个段落。
Rendering:
jQuery empty() method
jQuery empty() method deletes the selected The child elements of the element.
这是 div 中的一些文本。这是在 div 中的一个段落。
这是在 div 中的另外一个段落。
Rendering:
Recommended related video tutorials:jQuery Tutorial(Video)
The above is the detailed content of How to delete html elements with jquery. For more information, please follow other related articles on the PHP Chinese website!