Reputation: 3739
I'm trying to select multiple elements which do not have the attribute 'disabled' but I'm not sure if there's an easier way to type this:
$('input:not(:disabled), select:not(:disabled), textarea:not(:disabled)')
It seems a little wasteful to be typing multiple 'not(:disabled)'.
Upvotes: 1
Views: 1378
Reputation: 150020
Have you tried the .not()
method:
$('input, select, textarea').not(':disabled')
Which can be further simplified to:
$(':input').not(':disabled')
(Note that the ':input' selector selects button elements in addition to input, select and textarea elements.)
Upvotes: 0
Reputation: 298106
This should work:
$('input, select, textarea').filter(':enabled');
Or if you want to get really short:
$(':input:enabled')
Upvotes: 4
Reputation: 59578
you can use the :input selector along with the .not() method
$(':input').not(':disabled')
Upvotes: 0