2 回答
TA贡献1772条经验 获得超5个赞
我在火狐试了,我这没问题,代码
<select id="Mmonth">
<option>1</option>
</select>
<input type="button" onclick="a()" value="添加"/>
<script>
function a(){
document.getElementById("Mmonth").options.add(new Option(1, 1));
}
</script>
TA贡献1880条经验 获得超4个赞
<script type="text/javascript">
function addList(){
var list = document.getElementById("list");
var bb=["javascript1","javascript2","javascript3","javascript4"];
for(var i = 0; i <bb.length; i++){
var newOption = document.createElement("option");
newOption.setAttribute("value", i);
newOption.appendChild(document.createTextNode(bb[i]));
list.appendChild(newOption);
}
}
function clearList(){
var list = document.getElementById("list");
for(var i = list.options.length; i >= 0; i--){
list.remove(i);
}
}
</script>
</head>
<body>
<select name="list" id="list" style="width:120px">
</select>
<input type="button" onclick="addList()" value="生成"/>
<input type="button" onclick="clearList()" value="清空" />
</body>
添加回答
举报