The detach() is an inbuilt method in jQuery that removes the selected elements from the DOM tree including its all text and child nodes but it keeps the data and the events. Document Object Model (DOM) is a World Wide Web Consortium standard. This defines for accessing elements in the DOM tree.
Parameter:It does not accept any parameter.
Return Value: It returns the selected element with all removed texts and child nodes.
In the below code, all the paragraph element will detached.
Before clicking the “click Me” button-
After clicking the “click Me” button-