Jquery闪烁提示特效

12/6/2015来源:Javascript教程人气:1071

样式:.red{ border:1px solid #d00; background:#ffe9e8; color:#d00;}

 

function shake(ele,cls,times){           
        var i = 0,t= false ,o =ele.attr("class")+" ",c ="",times=times||2;

        if(t) return;

        t= setInterval(function(){

            i++;

            c = i%2 ? o+cls : o;

            ele.attr("class",c);

            if(i==2*times){

            	clearInterval(t);

            	ele.removeClass(cls);

            }

        },200);

     };

  调用:shake($("#ID"),"red",3);