control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/detach.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
1.2 KiB
JSON

{"name":"detach","type":"method","title":".detach()","deprecated":null,"removed":null,"desc":"Remove the set of matched elements from the DOM.","categories":["manipulation/dom-removal","version/1.4"],"entries":[{"return":"jQuery","signatures":{"added":"1.4","argument":{"desc":"A selector expression that filters the set of matched elements to be removed.","name":"selector","optional":"true","type":"Selector"}},"examples":{"desc":"Detach all paragraphs from the DOM","code":"\n$( \"p\" ).click(function() {\n $( this ).toggleClass( \"off\" );\n});\nvar p;\n$( \"button\" ).click(function() {\n if ( p ) {\n p.appendTo( \"body\" );\n p = null;\n } else {\n p = $( \"p\" ).detach();\n }\n});\n","css":"\n p {\n background: yellow;\n margin: 6px 0;\n }\n p.off {\n background: black;\n }\n","html":"\n<p>Hello</p>\nhow are\n<p>you?</p>\n<button>Attach/detach paragraphs</button>\n"},"longdesc":"\n <p>The <code>.detach()</code> method is the same as <code><a href=\"/remove/\">.remove()</a></code>, except that <code>.detach()</code> 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.</p>\n "}]}