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.
Set 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.net/n84AW/
精彩评论