html代码
复制代码 代码如下:
| |
| |
javascript代码如下:
复制代码 代码如下:
function listbox_remove(sourceID) {
//get the listbox object from id.
var src = document.getElementById(sourceID);
//iterate through each option of the listbox
for(var count= src.options.length-1; count >= 0; count--) {
//if the option is selected, delete the option
if(src.options[count].selected == true) {
try {
src.remove(count, null);
} catch(error) {
src.remove(count);
}
}
}
}
当然,如果使用jQuery来删除,那就方便了,一句话就搞定了
复制代码 代码如下:
$("#sourceId").find('option:selected').remove();



