87,907
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>a.html</title>
<script type="text/javascript">
function hello() {
var div = this.document.getElementById("div");
var select1 = this.document.createElement("select");
var option11 = this.document.createElement("option");
option11.setAttribute("id","option01");
var text = this.document.createTextNode("aaaaaaaaaaa");
option11.appendChild(text);
var option12 = this.document.createElement("option");
option12.setAttribute("id","option02");
var text = this.document.createTextNode("bbbbbbbbbbb");
option12.appendChild(text);
select1.appendChild(option11);
select1.appendChild(option12);
select1.setAttribute("onchange","hello();");
div.appendChild(select1);
}
</script>
</head>
<body>
<div id="div">
<select onchange="hello();">
<option value="a">aaaa</option>
<option value="b">bbbb</option>
</select>
</div>
</body>
</html>
select1.onchange=hello;