JQuery Programmer Question:
Download Job Interview Questions and Answers PDF
Explain .empty() vs .remove() vs .detach()?
Answer:
► .empty() method is used to remove all the child elements from matched elements.
► .remove() method is used to remove all the matched element. This method will remove all the jQuery data associated with the matched element.
► .detach() method is same as .remove() method except that the .detach() method doesn't remove jQuery data associated with the matched elements.
► .remove() is faster than .empty() or .detach() method.
Syntax:
$(selector).empty();
$(selector).remove();
$(selector).detach();
► .remove() method is used to remove all the matched element. This method will remove all the jQuery data associated with the matched element.
► .detach() method is same as .remove() method except that the .detach() method doesn't remove jQuery data associated with the matched elements.
► .remove() is faster than .empty() or .detach() method.
Syntax:
$(selector).empty();
$(selector).remove();
$(selector).detach();
Download JQuery Programmer Interview Questions And Answers
PDF
Previous Question | Next Question |
What is difference between $(this) and 'this' in jQuery? | What is jQuery.noConflict? |