闭包用法,延迟tab

var changeTab =( function () {
        var timeId = 0;
        return function (tabId) {
            if (timeId) {
                clearTimeout(timeId);
                timeId = 0;
            }
            timeId = setTimeout(function () {
                //ajax do something
            }, 500);
        };
    })();
原文地址:https://www.cnblogs.com/human/p/3469193.html