开发者

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

开发者 https://www.devze.com 2023-02-09 06:20 出处:网络
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 even

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

精彩评论

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