• JQuery Advanced


    1.Jquery Utility

    <1> Type & Function & setTimeOut

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="../../jquery/jquery-3.2.1.min.js"></script>
    </head>
    <body>
    
    <h1>Type test Functions demo</h1>
    <div id="output"></div>
    
    <script type="text/javascript">
        function addText() {
            $('#output').append('HelloWorld<br>');
        }
    
        function callAnotherFunction(times, delay, func) {
            var otimes = $.isNumeric(times)? times:3;
            var odelay = $.isNumeric(delay)? delay:300;
            if(!$.isFunction(func)){
                return false;
            }
    
            var i = 0;
            (function loopIt() {
                i++;
                func();
                if(i<times){
                    setTimeout(loopIt,delay);
                }
            })();
        }
    
        $(document).ready(function () {
            callAnotherFunction(3,300,addText);
        })
        
    </script>
    </body>
    </html>
    View Code

    N,多折叠板子

    html:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="../jquery-3.2.1.min.js"></script>
        <link rel="stylesheet" href="cp_01.css">
    </head>
    <body>
    
    <div class="collapse-body">
        <div class="clk-dialog">
            <h1>Collapse 01</h1>
            <p>Hello this is my all text here .button margin,padding,border should 0,
                必须要学习dom编程 RTFM RTFM,RTFM,RTFM</p>
        </div>
    
        <div class="clk-dialog">
            <h1>Collapse 02</h1>
            <p>Hello this is my all text here .button margin,padding,border should 0,
                必须要学习dom编程 RTFM RTFM,RTFM,RTFM</p>
        </div>
    
        <div class="clk-dialog">
            <h1>Collapse 03</h1>
            <p>Hello this is my all text here .button margin,padding,border should 0,
                必须要学习dom编程 RTFM RTFM,RTFM,RTFM</p>
        </div>
    
        <div class="clk-dialog">
            <h1>Collapse 04</h1>
            <p>Hello this is my all text here .button margin,padding,border should 0,
                必须要学习dom编程 RTFM RTFM,RTFM,RTFM</p>
        </div>
    </div>
    
    
    <script src="cp_01.js"></script>
    </body>
    </html>
    View Code

    css:

    body{
        background-color: #222222;
    }
    
    .collapse-body{
        /*position: relative;
        margin: auto;*/
        border: 1px solid #699;
        /*vertical-align: middle;*/
    
    }
    
    .clk-dialog{
        display: block;
        font-family: Consolas;
        color: white;
    
    }
    
    .clk-dialog h1{
        background: darkorange;
        border: 1px solid #222222;
        padding: 0;
        margin: 0;
        text-align: center;
    
    }
    .clk-dialog p{
        margin: 0;;
        padding: 0;
        border-bottom: 1px solid darkcyan;
    }
    View Code

    js:

    $(document).ready(function () {
        var dialog = $('.clk-dialog');
        var h1 = $('div.clk-dialog h1');
        var text = $('div.clk-dialog p');
    
        /*
        $(h1).click(function () {
            $(text).slideToggle(500);
        });*/
    
    
        $(dialog).each(function () {
            console.log($(this));
            var jq_h1 = $(this).children("h1");
            var jq_p  = $(this).children("p");
            $(jq_h1).click(function () {
                $(jq_p).slideToggle(500);
            })
        })
    });
    View Code
  • 相关阅读:
    java--对象引用与对象的区别
    小程序中js获取图片高度---多用于全屏广告图
    在WPF中显示GIF图片并实现循环播放
    在WPF中调用Winform控件
    开篇!WPF自定义控件(1)——转盘菜单
    【转】浅谈C#委托和事件
    给宝宝洗衣服,你应该按套路出牌
    代码复用,我应该知道的这些事
    Arrays.asList返回的List与new ArrayList的区别
    有关C++11标准的一些粗浅认识
  • 原文地址:https://www.cnblogs.com/gearslogy/p/8228427.html
Copyright © 2020-2023  润新知