Reema Reema - 6 months ago 52
jQuery Question

jquery - get input and select elements with id start and ends with

I have found how to get the elements whose id starts with

and ends with
as below: jQuery selector for matching at start AND end of ID?

$('[id ^=aName][id $=EditMode]')

I have also found how to get the elements of type input and select as below: jQuery find input type (but also for select)

$('input, select');

How can I combine both these to get all the input and select elements whose ids start with
and end with

Answer Source

Use .filter()

Reduce the set of matched elements to those that match the selector or pass the function's test.

$('input, select').filter('[id^=aName][id$=EditMode]')....

OR, Combine selectors

$('input[id^=aName][id$=EditMode], select[id^=aName][id$=EditMode]').....
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download