2011-03-03 63 views

回答

42

并列出来源:

$('input:not(:disabled):not([readonly])').each(function() { 
    $(this).foo(); 
}); 

或者更好:

$('input:enabled:not([readonly])').each(function() { 
    $(this).foo(); 
}); 

编辑: 从你以下的答案,那里有一个更好的方式做你想做的事:

$('input').focus(function(e) { 
    if($(this).is(':disabled, [readonly]')) { 
     $(this).next().focus(); 
     e.preventDefault(); 
    } 
}); 
0

我真的需要这些:

$('input:not(input:enabled:not([readonly]))').each(function() { 
//skip focus to readonly input 
    $(this).focus(function(){ 
     $(this).nextAll('input:enabled:not([readonly])')[0].focus(); 
    }); 
}); 
+1

你应该看看我最新的答案。有一个更干净的方式来做到这一点。 – Eric 2011-03-24 21:38:42

相关问题