jQuery has clean and cleanData methods. What is the purpose of jQuery clean and cleanData methods?
The empty() method removes all child nodes and content from the selected elements. Note: This method does not remove the element itself, or its attributes. Tip: To remove the elements without removing data and events, use the detach() method. Tip: To remove the elements and its data and events, use the remove() method.
removeData() method allows us to remove values that were previously set using jQuery. data() . When called with the name of a key, jQuery. removeData() deletes that particular value; when called with no arguments, all values are removed.
jQuery remove() Method The remove() method removes the selected elements, including all text and child nodes. This method also removes data and events of the selected elements. Tip: To remove the elements without removing data and events, use the detach() method instead.
Both are internal, undocumented methods, so you should not use them or rely on their current behavior, because they might change or disappear in the future.
That said, clean()
sanitizes the markup in the document fragments that are created from the HTML strings passed to some functions (most notably to $() itself).
cleanData()
frees the data associated with elements when they disappear from the DOM, e.g. through remove(), empty(), or html().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With