欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS動(dòng)態(tài)添加與刪除select中的Option對(duì)象(示例代碼)

 更新時(shí)間:2013年12月25日 09:42:28   作者:  
本篇文章主要介紹了JS動(dòng)態(tài)添加與刪除select中的Option對(duì)象示例代碼。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
如下所示:
復(fù)制代碼 代碼如下:

//動(dòng)態(tài)刪除select中的所有options:  
function delAllOptions(){ 
      document.getElementById("user_dm").options.length=0;  


//動(dòng)態(tài)刪除select中的某一項(xiàng)option:   
function delOneOption(index){ 
      document.getElementById("user_dm").options.remove(index);  

// 動(dòng)態(tài)添加select中的項(xiàng)option:   
function addOneOption(){ 
      //document.getElementById("user_dm").options.add(new Option(2,"mytest"));   

   var selectObj=document.getElementById("user_dm"); 
   alert(selectObj.length); 
   selectObj.options[selectObj.length] = new Option("mytest", "2"); 

相關(guān)文章

最新評(píng)論