Skip to content

Commit 1da4d7e

Browse files
committed
Animate demo: Don't use .toggle(fn).
1 parent 820cff8 commit 1da4d7e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

demos/animate/default.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@
1515
</style>
1616
<script>
1717
$(function() {
18-
$( "#button" ).toggle(
19-
function() {
18+
var state = true;
19+
$( "#button" ).click(function() {
20+
if ( state ) {
2021
$( "#effect" ).animate({
2122
backgroundColor: "#aa0000",
2223
color: "#fff",
2324
width: 500
2425
}, 1000 );
25-
},
26-
function() {
26+
} else {
2727
$( "#effect" ).animate({
2828
backgroundColor: "#fff",
2929
color: "#000",
3030
width: 240
3131
}, 1000 );
3232
}
33-
);
33+
state = !state;
34+
});
3435
});
3536
</script>
3637
</head>

0 commit comments

Comments
 (0)