闭包用法,延迟tab

var changeTab =( function () {
        var timeId = 0;
        return function (tabId) {
            if (timeId) {
                clearTimeout(timeId);
                timeId = 0;
            }
            timeId = setTimeout(function () {
                //ajax do something
            }, 500);
        };
    })();

 

posted @ 2013-12-11 13:24  sexy_girl  阅读(153)  评论(0编辑  收藏  举报