样式:.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);