Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  25] [ 4]  / answers: 1 / hits: 56012  / 11 Years ago, wed, september 18, 2013, 12:00:00

I have a select that contain this values:



<select id=lstCities class=valid name=City>
<option value=OSNY>OSNY</option>
<option value=dd>dd</option>
<option value=OSffNY>OSffNY</option>
<option value=ANTONY>ANTONY</option>
<option value=0>Autre...</option>
</select>


How can I delete all options but i would like to keep only



 <option value=0>Autre...</option>


My problem is my list is dynamic sometimes I have 3,5,7,.... select + the last one <option value=0>Autre...</option>


More From » jquery

 Answers
30

select all options, then exclude the one with that value :



$('#lstCities option[value!=0]').remove();


FIDDLE


[#75628] Tuesday, September 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ednakarolinal

Total Points: 187
Total Questions: 106
Total Answers: 118

Location: Saint Helena
Member since Mon, Jan 16, 2023
1 Year ago
;