js动态创建 select选择框

夹谷俊远
2023-12-01
document.body.onclick = function(){
    if(document.getElementById('vselect') === null){
         document.body.innerHTML = "";
         var select = document.createElement("select");
         select.setAttribute('id','vselect');
         select.options[0] = new Option("加载项1", "");
         select.options[1] = new Option("加载项2", "");
         this.appendChild(select);
    }
}

 

转载于:https://www.cnblogs.com/zhujiasheng/p/7106230.html

 类似资料: