JQuery选择没有禁用的所有元素并且没有只读?

jre*_*rey 15 jquery

使用JQuery,我需要选择具有条件的ALL INPUT元素:

'not disabled'(:禁用)'AND'''readonly',

然后我要改变css样式来查询结果.

更新:我需要按顺序迭代结果..

Eri*_*ric 43

冗长:

$('input:not(:disabled):not([readonly])').each(function() {
     $(this).foo();
});
Run Code Online (Sandbox Code Playgroud)

或更好:

$('input:enabled:not([readonly])').each(function() {
     $(this).foo();
});
Run Code Online (Sandbox Code Playgroud)

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

$('input').focus(function(e) {
    if($(this).is(':disabled, [readonly]')) {
        $(this).next().focus();
        e.preventDefault();
    }
});
Run Code Online (Sandbox Code Playgroud)