Примеры для jQuery .fadeToggle()


Fades first paragraph in or out, completing the animation within 600 milliseconds and using a linear easing. Fades last paragraph in or out for 200 milliseconds, inserting a "finished" message upon completion.

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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>fadeToggle demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<button>fadeToggle p1</button>
<button>fadeToggle p2</button>
<p>This paragraph has a slow, linear fade.</p>
<p>This paragraph has a fast animation.</p>
<div id="log"></div>
<script>
$( "button:first" ).click(function() {
$( "p:first" ).fadeToggle( "slow", "linear" );
});
$( "button:last" ).click(function() {
$( "p:last" ).fadeToggle( "fast", function() {
$( "#log" ).append( "<div>finished</div>" );
});
});
</script>
</body>
</html>

Демонстрация: