forms javascript jquery jquery-selectors

Select multiple descendants with jQuery?

I have this form:

<form name="customize">
Only show results within
<select name="distance" id="slct_distance">
<option value="10000" selected="selected">Any</option>
</select> miles of zip code
<input type="text" class="text" name="zip_code" id="txt_zip_code" />
<span id="customize_validation_msg"></span>

How can I select the input and select with one jQuery selector?

I tried this but it selected all of the selects and inputs on the page:

$("form[name="customize"] select,input")

The comma in the selector string separates completely separate expressions, just like in CSS, so the selector you’ve given gets the select elements within the form named “customize” and all inputs on the form (as you’ve described). It sounds like you want something like this:

$("form[name="customize"] select, form[name="customize"] input")

or if you’re not into repitition, this:

$("form[name="customize"]").children("select, input")