美文网首页
09jquery的淡入淡出的动画认识 fadeIn,fadeOu

09jquery的淡入淡出的动画认识 fadeIn,fadeOu

作者: An的杂货铺 | 来源:发表于2019-03-11 15:16 被阅读0次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            img {
                width: 200px;
                height: 200px;
                position: absolute;
                left: 0;
                bottom: 0;
                display: none;
            }
        </style>
    </head>
    <body>
        <button>显示</button>
        <button>隐藏</button>
        <button>切换</button>
        <button>淡入到</button>
        <br>
        
        <img src="1.jpeg"></img>
        <script src="./jquery-1.12.1.min.js"></script>
        <script>
            // 点击显示按钮 图片显示
            $('button:eq(0)').on('click',function(){
                $('img').fadeIn(1000);
            })
    
            // 点击隐藏按钮 图片隐藏
            $('button:eq(1)').on('click',function(){
                $('img').fadeOut(1000);
            })
    
            $('button:eq(2)').on('click',function(){
                $('img').fadeToggle(1000);
                // $('img').toggle(1000);
            })
    
            //将透明度切换为0.3
           $('button:eq(3)').on('click',function(){
            $('img').fadeTo(1000,0.3)
           })
        </script>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:09jquery的淡入淡出的动画认识 fadeIn,fadeOu

          本文链接:https://www.haomeiwen.com/subject/xhlbpqtx.html