1 Answers
jQuery Interview Question: Difference between hide() and detach() methods
The hide()
method in jQuery is used to hide the selected elements by changing their visibility to "none", but the elements still occupy space on the page.
On the other hand, the detach()
method in jQuery is used to remove the selected elements from the DOM (Document Object Model) completely, which means they are no longer part of the page and do not occupy any space.
So, the main difference between hide()
and detach()
methods in jQuery is that hide()
hides the elements but they still exist in the DOM whereas detach()
removes the elements from the DOM entirely.
Please login or Register to submit your answer