我使用下面的函數進行驗證:發現哪一類引發模糊
//Validation
$('.sValidate').bind('blur', function() {
if (!$(this).val()) {
$(this).removeClass('short_input');
$(this).addClass('short_input_negative');
return false;
}
});
我的大部分輸入類是short_input
。但其中一些也被命名爲long_input
。
我如何知道input
觸發blur
的級別,刪除它並添加long_input_negative
?
<input type="text" id="loginname" name="loginname" class="short_input sValidate" value="JDoe">
一個類不能觸發事件 – Alp
@Alp這是可能的結合由jQuery選擇返回的任何元素。更多信息:http://api.jquery.com/bind/ –