美文网首页
jQuery-day05

jQuery-day05

作者: Rosemarry丶 | 来源:发表于2017-12-27 20:36 被阅读0次

A我今天学了什么

1.jq效果

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            .box{
                margin-top: 50px;
                width: 500px;
                height: 400px;
                background: chocolate;
                display: none;
            }
            button{
                width: 200px;
                height: 40px;
                font-size: 20px;
                margin: 10px 20px;
            }
        </style>
        <script type="text/javascript" src="js/jquery-3.2.1.min.js" ></script>
        <script type="text/javascript">
            $(function(){
                var btn = $('button');
                var box = $('.box');
                //今天学习JQ基本效果
                //把隐藏的显示出来
                //1.show(动画时间,动画结束之后执行的回调函数)
                
                /*btn.eq(0).click(function(){
                    box.show(5000,function(){
                        alert('我显示完啦')
                    })
                })
                
                
                //2.hide()隐藏,参数和上面一样
                btn.eq(1).click(function(){
                    box.hide(5000,function(){
                        alert('我彻底隐藏了')
                    })
                    
                })*/
                
                /*//3.slideDown()向下展开,效果和show是一样的,只不过显示的方式不同而已
                btn.eq(2).click(function(){
                    box.slideDown(5000,function(){
                        alert('slideDown')
                    })
                })
                
                //4.slideUp()向上隐藏
                
                btn.eq(3).click(function(){
                    box.slideUp(5000,function(){
                        alert('slideUp')
                    })
                })
                
                //5.slideToggle()隐藏变显示,显示变隐藏
                btn.eq(4).click(function(){
                    box.slideToggle(3000,function(){
                        alert('slideToggle')
                    })
                })*/
                
                //6.淡入淡出
                //1.fadeIn()让隐藏的淡出,最终效果是去掉display=none
                btn.eq(5).click(function(){
                    box.fadeIn(3000,function(){
                        alert('fadeIn')
                    })
                })
                
                //2.fadeOut()让显示的淡入,添加display=block
                
                btn.eq(6).click(function(){
                    box.fadeOut(3000,function(){
                        alert('fadeOut')
                    })
                })
                
                btn.eq(7).click(function(){
                    box.fadeToggle(3000,function(){
                        alert('fadeToggle')
                    })
                })
                
                //让透明度到指定位置
                btn.eq(8).click(function(){
                    box.fadeTo(3000,0.5,function(){
                        alert('fadeToggle')
                    })
                })
                
            });
            
        </script>
    </head>
    <body>
        <!--基本-->
        <button>show</button>
        <button>hide</button>
        <!--滑动-->
        <button>sliderDown</button>
        <button>sliderUp</button>
        <button>sliderToggle</button>
        <!--淡入淡出-->
        <button>fadeIn</button>
        <button>fadeOut</button>
        <button>fedeToggle</button>
        
        <button>fadeTo</button>
        
        <div class="box"></div>
    </body>
</html>

相关文章

网友评论

      本文标题:jQuery-day05

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