jquery - Dropdown doesn't contain empty value, still gets selected -


this question has answer here:

i have weird issue.

i have dropdown no empty value option i.e.

<option value="">select</option> 

my dropdown:

<select name="dropdown" id="dropdown">     <option value="0">option 0</option>     <option value="1">option 1</option> </select> 

however, when set the dropdown value so:

$('#dropdown').val("") 

the dropdown shows empty option eventhough there no such option available in list. why happen? i've checked code , html , don't find empty option or code sets empty option.

what cause of this?

if pass non existing value(it not necessary pass "" ) method clear select element since there no matching option. therefore use selected index select option dynamically.

$("#list")[0].selectedindex = 1; 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -