JQuery基础学习(三) 实现淡入淡出效果

其实淡入淡出效果也是很简单的,直接上代码吧,权当做个笔记。

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>淡入淡出</title>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    function ShowMessage(str)
    {
        alert(str);
    }
    function fadeOutClick()
    {
        $("#div1").fadeOut();
        $("#div2").fadeOut("slow");
        $("#div3").fadeOut(3000,ShowMessage("成功淡出"));
    }
    function fadeInClick()
    {
        $("#div1").fadeIn();
        $("#div2").fadeIn("slow");
        $("#div3").fadeIn(3000, ShowMessage("成功淡入"));
    }
</script>
</head>

<body>
    <p>演示带有不同参数的 fadeOut() 方法。</p>
    <button onclick="fadeOutClick()">点击这里,使三个矩形淡出</button>
    <br/><br/>
    <button onclick="fadeInClick()">点击这里,使三个矩形淡入</button>
    <br/>
    <div id="div1" style="80px;height:80px;background-color:red;"></div>
    <br/>
    <div id="div2" style="80px;height:80px;background-color:green;"></div>
    <br/>
    <div id="div3" style="80px;height:80px;background-color:blue;"></div>
</body>
</html>
原文地址:https://www.cnblogs.com/FirstCode/p/2937254.html