.detach( [selector ] )Returns: jQuery
Description: Remove the set of matched elements from the DOM.
-
version added: 1.4.detach( [selector ] )
-
selectorType: SelectorA selector expression that filters the set of matched elements to be removed.
-
The .detach()
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.
Example:
Detach all paragraphs from the DOM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
|