2010-09-28 30 views

回答

0
function RemoveItems() 
{ 
    var objDrpList = document.getElementById ('theIdOfYourDdl'); 

    for(i=objDrpList.length-1; i>=0; i--) 
    { 
     if(objDrpList.options[i].selected) 
     { 
     objDrpList.options[i] = null; 
     } 
    } 
} 

編輯:

Darin的回答居然是要走的路。兩者都可以工作,但代碼越少越好。

8
document.getElementById('idofselectbox').options.length = 0;