Deselect selected options by Javascript

امیرحسین لطیفی - ۱۷ مهر ۱۳۸۶

To deselect selected option(s) of a Select tag in HTML you can use this JS code:
document.getElementById(selectTagId).selectedIndex = -1;
selectTagId is Id of Select tag.
selectedIndex property is:
index of selected option,
it’s index of first selection in multi selection case,
starts from zero,
it’s ‘-1′ when no option is selected.
More about selectedIndex property and uses:
selectedIndex Property on MSDN
Working with selectedIndex