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


Animates all hidden paragraphs to show slowly, completing the animation within 600 milliseconds.

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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>show demo</title>
<style>
p {
background: yellow;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<button>Show it</button>
<p style="display: none">Hello 2</p>
<script>
$( "button" ).click(function() {
$( "p" ).show( "slow" );
});
</script>
</body>
</html>

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

Show the first div, followed by each next adjacent sibling div in order, with a 200ms animation. Each animation starts when the previous sibling div's animation ends.

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
29
30
31
32
33
34
35
36
37
38
39
40
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>show demo</title>
<style>
div {
background: #def3ca;
margin: 3px;
width: 80px;
display: none;
float: left;
text-align: center;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<button id="showr">Show</button>
<button id="hidr">Hide</button>
<div>Hello 3,</div>
<div>how</div>
<div>are</div>
<div>you?</div>
<script>
$( "#showr" ).click(function() {
$( "div" ).first().show( "fast", function showNext() {
$( this ).next( "div" ).show( "fast", showNext );
});
});
$( "#hidr" ).click(function() {
$( "div" ).hide( 1000 );
});
</script>
</body>
</html>

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

Show all span and input elements with an animation. Change the text once the animation is done.

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>show demo</title>
<style>
span {
display: none;
}
div {
display: none;
}
p {
font-weight: bold;
background-color: #fcd;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<button>Do it!</button>
<span>Are you sure? (type 'yes' if you are) </span>
<div>
<form>
<input type="text" value="as;ldkfjalsdf">
</form>
</div>
<p style="display:none;">I'm hidden...</p>
<script>
function doIt() {
$( "span,div" ).show( "slow" );
}
// Can pass in function name
$( "button" ).click( doIt );
$( "form" ).submit(function( event ) {
if ( $( "input" ).val() === "yes" ) {
$( "p" ).show( 4000, function() {
$( this ).text( "Ok, DONE! (now showing)" );
});
}
$( "span,div" ).hide( "fast" );
// Prevent form submission
event.preventDefault();
});
</script>
</body>
</html>

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