开发者

How to remove selection from a listbox in html by javascript and jQuery?

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜