Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of jQuery clean and cleanData methods?

Tags:

jquery

jQuery has clean and cleanData methods. What is the purpose of jQuery clean and cleanData methods?

like image 859
dev.e.loper Avatar asked Aug 16 '11 19:08

dev.e.loper


People also ask

How to clear the data in jQuery?

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.

What does removeData do in jQuery?

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.

How to remove variable in jQuery?

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.


1 Answers

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().

like image 98
Frédéric Hamidi Avatar answered Nov 01 '22 12:11

Frédéric Hamidi