Is there a jquery select for multiple form elements?
i want to get back an array of all:
- hidden inputs
- text inputs
- select inputs
- checkboxes
I see this page but it s开发者_如何转开发eems like you have to query for checkboxes seperately
is there anyway to have one selector get everything in one array?
This will return what you're looking for I think...
$("input:hidden, input:text, select, input[type='checkbox']")
I'm not sure if you needed this or not as well but for text areas you'd also want to add...
$("textarea")
Depending on your goal, $('your_form_here').serialize()
might be what you're looking for. It takes all values from a form, in order to for example submit it via AJAX.
See the docs on serialize()
Try these selectors:
- All hidden
input
s:input[type=hidden]
- All text
input
s:input[type=text], input:not([type])
- All
select
s:select
- All checkboxes:
input[type=checkbox]
$('input, select')
perhaps?
$('input:hidden, input:text, input:checkbox, select')
精彩评论