开发者

Is there a jquery select for multiple form elements?

i want to get back an array of all:

  1. hidden inputs
  2. text inputs
  3. select inputs
  4. 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:

  1. All hidden inputs: input[type=hidden]
  2. All text inputs: input[type=text], input:not([type])
  3. All selects: select
  4. All checkboxes: input[type=checkbox]


$('input, select') perhaps?


$('input:hidden, input:text, input:checkbox, select')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜