I’m using the below selector to get all the form inputs that are pre-populated with a value.
$('input[value!=""]');
This works great and so I thought I could apply the same logic to my select elements using the following selector, though it seems to be selecting all the select elements in Chrome.
$('select[value!=""]');
Below is an example of two types of selects on the form:
<select name="phone2_type" id="phone2_type">
<option value="">Select one:</option>
<option value="HOME">Home</option>
<option value="CELL">Cell</option>
<option value="BUSN">Business</option>
</select>
<select name="state" id="state">
<option value="">Select one:</option>
<option value="XX">Outside USA/Canada</option>
<option value="AL" selected="selected">Alabama</option>
<option value="AK">Alaska</option>
...
</select>
I’d like to select the second select since it has a value selected already with the select=”selected”
valueis not an attribute ofselecttag.So you need to try: