ONYX
ONYX

Reputation: 5859

How to select different input type at the same time?

Is it possible to do something like this in jQuery to select multiple input control so that I can bind the onchange event on all of them at the same time.

jQuery('div input[type=(text|select|radio|checkbox)]')

or is it something like this jQuery('div input[type=*]') ?

Upvotes: 2

Views: 427

Answers (2)

karim79
karim79

Reputation: 342635

Check out the :input selector:

jQuery("div :input").change(...

The API states that it "Selects all input, textarea, select and button elements".

If you are looking to select a subset of input types within a container, you could use the multiple selector, like this:

jQuery("div input[type=radio], input[type=text]").change(...

Upvotes: 2

Corey Sunwold
Corey Sunwold

Reputation: 10254

jQuery('div input').change(function() {
    //code
});

Upvotes: 1

Related Questions