Chris Conway
Chris Conway

Reputation: 16519

how can i get all inputs excluding buttons and hidden fields with jquery?

I've got the following which will excludes all buttons, but how can I also exclude hidden fields?

$("#selector").find(":input:not(:button)").each(function (i) { // do something

I'm sure this is probably simple, I just can't find it.

Many thanks!

Upvotes: 19

Views: 18575

Answers (4)

Jadeye
Jadeye

Reputation: 4309

For me, (jquery 2.2.0)

DID NOT WORK

$('#signup-form :input:not(:hidden :button)').each(function(){
$('#signup-form :input').not(':hidden :button').each(function(){
$('#signup-form *').filter(':input:not([type=hidden][type=button])').each(function(){

DID

$('#signup-form *').filter(':input').not(':button').not('input[type=hidden]').each(function(){

OR

$('#signup-form :input').not(':hidden').not(':button').each(function(){

Upvotes: 1

Gabriele Petrioli
Gabriele Petrioli

Reputation: 196002

the following code should do it..

$('#selector :input').not(':button,:hidden').each(...);

Upvotes: 42

Marcis
Marcis

Reputation: 4617

$("#selector :input:not(:button, :hidden)").each(function (i) { // do something

Upvotes: 4

jAndy
jAndy

Reputation: 236022

$('#selector').find('input').not(':button').not('input[type=hidden]').each(function(i) {
});

should do it. I'm not sure if this one

$('#selector').find('input').not(':button').not(':hidden').each(function(i) {
});

also works for that purpose, but its worth a try.

Upvotes: 6

Related Questions