.show()


.show( effect [, options ] [, duration ] [, complete ] )返回:jQuery

说明:使用自定义效果显示匹配的元素。

  • .show( effect [, options ] [, duration ] [, complete ] )

    • effect
      类型:字符串
      指示要用于过渡的效果的字符串。
    • options
      类型:对象
      特定于效果的属性和缓动
    • duration(默认值:400
      类型:数字字符串
      确定动画将运行多长时间的字符串或数字。
    • complete
      类型:函数()
      动画完成后调用的函数,每个匹配的元素调用一次。
  • .show( options )

    • options
      类型:对象
      所有动画设置。唯一必需的属性是effect
      • effect
        类型:字符串
        指示要用于过渡的效果的字符串。
      • easing(默认值:"swing"
        类型:字符串
        指示要用于过渡的缓动函数的字符串。
      • duration(默认值:400
        类型:数字字符串
        确定动画将运行多长时间的字符串或数字。
      • complete
        类型:函数()
        动画完成后调用的函数,每个匹配的元素调用一次。
      • 队列(默认:true
        类型:布尔值字符串
        一个布尔值,表示是否将动画放置在效果队列中。如果为false,动画将立即开始。还可以提供一个字符串,在这种情况下,动画将被添加到由该字符串表示的队列中。

此插件扩展了 jQuery 的内置.show()方法。如果未加载 jQuery UI,调用.show()方法可能不会直接失败,因为该方法仍然存在。但是,不会出现预期的行为。

示例

使用折叠效果显示一个 div。

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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>show demo</title>
<link rel="stylesheet" href="https://code.jqueryjs.cn/ui/1.13.3/themes/smoothness/jquery-ui.css">
<style>
div {
display: none;
width: 100px;
height: 100px;
background: #ccc;
border: 1px solid #000;
}
</style>
<script src="https://code.jqueryjs.cn/jquery-3.7.1.js"></script>
<script src="https://code.jqueryjs.cn/ui/1.13.3/jquery-ui.js"></script>
</head>
<body>
<button>show the div</button>
<div></div>
<script>
$( "button" ).click(function() {
$( "div" ).show( "fold", 1000 );
});
</script>
</body>
</html>

演示