Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery select all elements without disabled AND no readonly?

Tags:

jquery

With JQuery, I need to select ALL INPUT elements with a condition:

'NOT disabled' (:disabled) 'AND' 'NOT readonly',

and then i'm gonna change css style to query result.

UPDATE: I need iterate over result in order..

like image 536
jrey Avatar asked Mar 03 '11 16:03

jrey


1 Answers

Verbosely:

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

Or better:

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

EDIT: From your following answer, theres a better way of doing what you want to do:

$('input').focus(function(e) {
    if($(this).is(':disabled, [readonly]')) {
        $(this).next().focus();
        e.preventDefault();
    }
});
like image 60
Eric Avatar answered Sep 19 '22 15:09

Eric