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)'.
This should work:
$('input, select, textarea').filter(':enabled');
Or if you want to get really short:
$(':input:enabled')
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.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.