Skip to content

Commit 6c679d5

Browse files
committed
unwrap: Remove deprecated use of .toggle( fn, fn ) - Fixes jquerygh-248
1 parent 0faee1c commit 6c679d5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

entries/unwrap.xml

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
<example>
1212
<desc>Wrap/unwrap a div around each of the paragraphs.</desc>
1313
<code><![CDATA[
14-
$("button").toggle(function(){
15-
$("p").wrap("<div></div>");
16-
}, function(){
17-
$("p").unwrap();
14+
var pTags = $("p");
15+
$("button").click( function(){
16+
if ( pTags.parent().is("div") ) {
17+
pTags.unwrap();
18+
} else {
19+
pTags.wrap("<div></div>");
20+
}
1821
});]]></code>
1922
<css><![CDATA[
2023
div { border: 2px solid blue; }
@@ -28,4 +31,4 @@ $("button").toggle(function(){
2831
<category slug="manipulation/dom-insertion-around"/>
2932
<category slug="manipulation/dom-removal"/>
3033
<category slug="version/1.4"/>
31-
</entry>
34+
</entry>

0 commit comments

Comments
 (0)