做一個表單驗證。如果字段未通過驗證,我希望更改顏色並動搖字段。我的代碼:jQuery動畫不會晃動元素
$('#'+vet)
.css({'background-color':'yellow','border-color':'red'})
.animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100)
.animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100)
.animate({ left: "0px" }, 100);
它確實會改變字段背景和邊框顏色,但字段不會晃動。
有什麼想法?
或者,使用jQuery UI的搖動效果。 http://api.jqueryui.com/shake-effect/ – Thew