首页 > 其他 > 详细

jq常用函数

时间:2019-09-16 11:09:36      阅读:85      评论:0      收藏:0      [点我收藏+]

hide();

<div class="box">big box</div>
$(‘.box‘).hide(5000, function(){ console.log(‘hhhhh‘); }); //hide() h设置隐藏元素 //5000 是用5000ms内实现这个元素消失效果 // 内部函数是回调函数callback,是5000ms后调用的函数
   //也可以不接收参数
   //接收的参数是时间值 和 一个执行结束后的回调

(css样式省略)

浏览器中元素会逐渐消失,消失后控制台打印内容

show();

   .hide-box {
        height: 200px;
        background-color: rgb(25, 99, 25);
        font-size: 60px;
        text-align: center;
        line-height: 200px;
        color: white;
        display: none;
    }


    <div class="hide-box">big box</div>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>

    <script>
        $(‘.hide-box‘).show(5000, function(){
            console.log(‘hhhhh‘);
        });
   </script>

show(); 让一个隐藏的按钮显示

举个栗子:

点击按钮让图片切换隐藏显示

 .box {
        height: 200px;
        background-color: rgb(25, 99, 25);
        font-size: 60px;
        text-align: center;
        line-height: 200px;
        color: white;
    }


    <button class="btn">button</button>
    <div class="box">big box</div>

 

 $(‘.btn‘).click(function(){
            $(‘.box‘).toggle(5000,function(){
                console.log(11);
                
            });
        });
        // 可以不接收参数
        // 可以接受一个时间参数,作为切换的时间
        //也可以接受一个回调函数,执行一次切换执行一次回调

 

jq常用函数

原文:https://www.cnblogs.com/sandraryan/p/11525968.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!