[ jquery 效果 show([speed,[easing],[fn]]) hide([speed,[easing],[fn]]) ] 此方法用于显示隐藏的被选元素:show() 适用于通过 jQuery 方法和 CSS 中 display:none type='hidden' 隐藏的元素(不适用于通过 visibility:hidden 隐藏的元素)

show()显示隐藏的被选元素:show() 适用于通过 jQuery 方法和 CSS 中 display:none type='hidden' 隐藏的元素(不适用于通过 visibility:hidden 隐藏的元素):

hide() 方法隐藏被选元素:

参数描述
speed 可选。规定显示效果的速度。

可能的值:

  • 毫秒
  • "slow"
  • "fast"
easing 可选。规定在动画的不同点上元素的速度。默认值为 "swing"。

可能的值:

  • "swing" - 在开头/结尾移动慢,在中间移动快
  • "linear" - 匀速移动
提示:扩展插件中提供更多可用的 easing 函数。
callback 可选。show() 方法执行完之后,要执行的函数。

如需学习更多有关 callback 的内容,请访问我们的 jQuery Callback 这一章。

<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta http-equiv='description' content='this is my page'>
<meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type="text/css">
    *{margin:0;padding:0;}
    html{font:400 15px/1.2em 'Courier New';color:#666;750px;margin:25px auto;}
    #show{450px;height:25px;background:red;display:none;color:#FFF;line-height:25px;text-indent:8px;padding:10px;margin:200px;}
    .wrapAll{color:#FF96EC;}
</style>
<script type='text/javascript'>
    $(function(){
        $('#show').show(1000,'linear',function(){
            
            /*
                show : 执行动画的原理:
                    在设置速度的情况下,元素从可见到隐藏的过程中,会逐渐地改变其高度、宽度、外边距、内边距和透明度,反之亦然...
            其实说白了就是先设置可以影响显示|隐藏的元素属性,然后是外边距和内边距等之间的属性....这就好理解了吧...
*/ $(this).hide(3000,'swing',function(){
      /*

          其实就是在行间设置 style='display:none';属性
       */

                console.log('already Finished...');

            });
        });
    });
</script>
</head>
<body>
    <div id='demo'>
        <div id='show'>Test text</div>
    </div>
</body>
</html>
原文地址:https://www.cnblogs.com/mysearchblog/p/5619095.html