var iSpace = (function(){ var shzt = $("#shzt"),zcsj=$("#zcsj"),shsj=$("#shsj"); var arr = []; var sTime = 700; Array.prototype.push.call(arr,shzt,zcsj,shsj); var throttle = function(fn,interval){ var _self = fn, timer, firsttime = true; return function(){ var args = arguments, _me = this; if(firsttime){ _self.apply(_me,args); return firsttime = false; } if(timer){return false;} timer = setTimeout(function(){ clearTimeout(timer); timer = null; _self.apply(_me,args); },interval||500) } } for(var i=0;i<arr.length;i++){ (function(i){ arr[i].toggle(throttle(function(){ $(this).addClass("uptime");//改状态 $(this).siblings('a').removeClass("uptime"); //一些事件 },sTime),throttle(function(){ $(this).removeClass("uptime"); },sTime)) })(i); } })();