为了满足我的需要,我使用
$('#form :input').each( function(i) {
if ( !$(this).hasClass('donot') ) {
$(this).attr('disabled', 'disabled');
}
});
是否有更好的方法不使用if条件来检查输入是否具有“donot”类?
感谢您的帮助...
克里斯
最佳答案
$('#form input:not(.donot)').each( function(i) {
$(this).attr('disabled', 'disabled');
});
就这样吧:-D
<小时/>或者你也可以这样做:
$('#form input').not('.donot').each( function(i) {
$(this).attr('disabled', 'disabled');
});
关于jquery 每个输入都有Class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8406680/