js 移除select选中项

// 移除选中项
function removeOption() {
            
    var selectIndex = []
            
    var options = null
           
    var selectBox = document.getElementById('selLocation')
            
    for (var i = 0, len = selectBox.options.length; i < len; i++) {
                
        options = selectBox.options[i]
                
        if (options.selected) {
                    
            selectIndex.push(i)
                
        }
            
    }
            
    selectIndex.forEach((element) => {
                
        document.getElementById('selLocation').remove(selectIndex.length-1)

            
    });
}

 

你可能感兴趣的:(Javascript)