1. ReplaceWith method
Replaces all matching elements in the collection with the provided content and returns the collection of substituted elements
Parameter type description:
1) Normal string (can contain various HTML tags)
2) JQuery Object
① new element created with the $ function (jquery object)
② using the $ function to get the elements already in the page (jquery objects)
The existing elements are moved to the new location
③ using the Clone method to clone an existing element in a page (jquery object)
3) HTML element object, HTML element object array
4) function
How many matches are there, and how many times this function executes!
The function can accept two parameters: the first is the ordinal of the current element, and the second is the HTML within the current element.
Inside the function this represents the current HTML element object
The return data is the replacement content (can be HTML elements, or jquery objects)
2. ReplaceAll method
Replace each target element with a matching element of the collection (same as ReplaceWith)
Differences from Replacewitch:
Target and Source opposite
Creates a new element that returns the JQuery object associated with the
This method can be called by a jquery object that has elements returned from the selected page (selecting an existing element in the page means moving an existing element to the target element)!
Parameter (indicates the target location to insert the element):
Selector or jquery object or HTML element object/html element Object array
3. Detach () method
Removes the matched element from the page and returns the call to the element jquery object
Parameter description:
(optional) A selector filters the elements that need to be removed from the matching elements
4. Empty () method
Removes all descendant elements (including text) of a matching element from the page
5. Remove () method
Removes the matching element collection from the page, returning the call to the element jquery object (while removing the event handler and associated data on the element)
If you delete an element, you do not need to delete the associated data and events, use Detach ()
Parameter description:
(optional) A selector to filter the collection of matched elements to be removed
6. Unwrap () method
Deletes the parent element of the matching element collection, preserving itself (and the sibling element, if present) in its original position
jquery-replacing and deleting elements