Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to set the default value of a drop down as empty; ie not selecting any value.

$dropdown.prop("selectedIndex", -1);

It works in IE and chrome, but doesn't work in Firefox. In Firefox, it always set the first value of the drop down as default value.

I am using Mozilla version 23.0.1.
Posted

1 solution

Try the following JQuery codes:
JavaScript
//with single quotes
$dropdown.prop('selectedIndex', -1);

//or with attr
$dropdown.attr('selectedIndex', -1);


Or if it is possible update your JQuery version if you use older one.

I hope it could help you!
 
Share this answer
 
Comments
user1726 17-Sep-13 14:59pm    
Thanks for your response.
I tried both the solutions but it didn't work.
Using single quotes, didn't make any difference
Using attribute, doesn't work in IE and chrome too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900