New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jwait

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwait

a jquery plugin ,which provide a easy way to delay your work

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

jWait

a jquery plugin ,which provide a easy way to delay your work 为了少写几个setTimeout,哈哈

示例代码

原来

    setTimeout(function (){
        $('#b_1').addClass('active');
    },1000);

现在

    $('#b_1').jWait(1000).addClass('active');

原来 yet

    setTimeout(function (){
        $('#b_1').addClass('active');
        
        setTimeout(function (){
            $('#b_2').css({color:red});
        },1000);
    },1000);

==> 现在 now

    $('#b_1').jWait(1000).addClass('active')
             .jWait(1000)
             .jWait('#b_2').css({color:red});

原来 yet

    function doSth(){
        //...
    }

    setTimeout(function (){
        $('#b_1').addClass('active');
        doSth();
        setTimeout(function (){
            doSth();
            $('#b_2').css({color:red});
        },1000);
    },1000);

==> 现在 now

    function doSth(){
        //...
    }   
    
    $('#b_1').jWait(1000).addClass('active').jWait(doSth)
             .jWait(1000).jWait(doSth)
             .jWait('#b_2').css({color:red});

参数

/**
 *
 * @param waitObj  绑定对象可以是 (数字,字符串,对象,方法)
 * 1.数字 表示延迟的时间(单位:毫秒)
 * 2.字符串 查询字符串querySelector,表示切换代理的对象为查询字符串代表的jquery对象
 * 3.对象 代理的对象,表示切换代理的对象
 * 4.方法 延迟后执行的函数,如果没有延迟,则直接执行
 *
 * @param callback 回调方法,只有当waitObj是数字类型时有效
 * @returns {jWaitProxy} 返回一个执行代理对象,一个神奇的对象
 */
$.fn.jWait = function (waitObj, callback) {
//....
}

Keywords

jquery

FAQs

Package last updated on 24 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts