What is the difference between .empty(), .remove() and .detach() methods in jQuery?

Answer

All these methods .empty(), .remove() and .detach() are used for removing elements from DOM but they all are different.  
.empty(): This method removes all the child element of the matched element where remove() method removes set of matched elements from DOM.  
.remove(): Use .remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.  
.detach(): This method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time.

All JQUERY Questions

Ask your interview questions on jquery

Write Your comment or Questions if you want the answers on jquery from jquery Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---