[JavaScript] JavaScript从列表框中一次删除多个选中的元素 →→→→→进入此内容的聊天室

来自 , 2021-03-11, 写在 JavaScript, 查看 115 次.
URL http://www.code666.cn/view/1b727462
  1. function selectBoxRemove(sourceID) {
  2.  
  3.     //get the listbox object from id.
  4.     var src = document.getElementById(sourceID);
  5.    
  6.     //iterate through each option of the listbox
  7.     for(var count= src.options.length-1; count >= 0; count--) {
  8.  
  9.          //if the option is selected, delete the option http://www.sharejs.com
  10.         if(src.options[count].selected == true) {
  11.    
  12.                 try {
  13.                          src.remove(count, null);
  14.                          
  15.                  } catch(error) {
  16.                          
  17.                          src.remove(count);
  18.                 }
  19.         }
  20.     }
  21. }
  22.  
  23.  
  24. //javascript/8785

回复 "JavaScript从列表框中一次删除多个选中的元素"

这儿你可以回复上面这条便签

captcha