After I click an item on a listbox, I'll do this processing then I need to remove this selection as it was at the first time so that I can click the same item again and fire the event of selected index change.
After I click an item on a listbox, I'll do this processing then I need to remove this selection as it was at the first time so that I can click the same item again and fire the event of selected index change.
Share Improve this question asked Feb 9, 2011 at 14:20 Ahmad FaridAhmad Farid 14.8k45 gold badges98 silver badges138 bronze badges 1- do you need any more help with this question? :-) – Andy E Commented Feb 15, 2011 at 9:57
1 Answer
Reset to default 8Set the selectedIndex
property to -1:
// Plain JS:
document.getElementById("myList").selectedIndex = -1;
// Using jQuery to select the element:
$("#myList")[0].selectedIndex = -1;
Working demo: http://jsfiddle/n84AW/