2011-03-03 64 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

相關問題