JQuery选择所有元素没有禁用和不只读?
问题描述:
使用jQuery,我需要选择符合条件所有输入单元:JQuery选择所有元素没有禁用和不只读?
“NOT禁用”(关闭)“和”“不是只读”,
,然后我将要改变的CSS样式查询结果。
更新:我需要的结果遍历为了..
答
并列出来源:
$('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();
}
});
答
我真的需要这些:
$('input:not(input:enabled:not([readonly]))').each(function() {
//skip focus to readonly input
$(this).focus(function(){
$(this).nextAll('input:enabled:not([readonly])')[0].focus();
});
});
你应该看看我最新的答案。有一个更干净的方式来做到这一点。 – Eric 2011-03-24 21:38:42