JQuery选择没有禁用的所有元素并且没有只读?
使用JQuery,我需要选择具有条件的ALL INPUT元素:
‘not disabled’(:禁用)’AND”NOT readonly’,
然后我要改变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(); }); });