We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0faee1c commit 6c679d5Copy full SHA for 6c679d5
entries/unwrap.xml
@@ -11,10 +11,13 @@
11
<example>
12
<desc>Wrap/unwrap a div around each of the paragraphs.</desc>
13
<code><![CDATA[
14
-$("button").toggle(function(){
15
- $("p").wrap("<div></div>");
16
-}, function(){
17
- $("p").unwrap();
+var pTags = $("p");
+$("button").click( function(){
+ if ( pTags.parent().is("div") ) {
+ pTags.unwrap();
18
+ } else {
19
+ pTags.wrap("<div></div>");
20
+ }
21
});]]></code>
22
<css><![CDATA[
23
div { border: 2px solid blue; }
@@ -28,4 +31,4 @@ $("button").toggle(function(){
28
31
<category slug="manipulation/dom-insertion-around"/>
29
32
<category slug="manipulation/dom-removal"/>
30
33
<category slug="version/1.4"/>
-</entry>
34
+</entry>
0 commit comments