我有4個輸入字段和一個公共類名。我用它來檢查它是否空白。獲取一個空白輸入字段的ID
var blank = $('.fourFields').filter(function(){
return !$.trim($(this).val()).length;
}).length;
if(!blank){
//do something
} else {
//how do I use addClass() to the blank input fields here?
}
我的問題是如何獲得空白輸入字段的ID?
$(this).attr('id') – ItayB
@ ItayB - 或者更高效:'this.id'。 – RobG
@ RobG-你是對的;-)謝謝 – ItayB