网页前端JavaScript实现选择select下拉菜单中的选项添加文本框功能
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function testClk(){
var input1 = document.createElement('input');
var obj = document.getElementById("org");
if (obj.value == "是")
{
input1.setAttribute('type', 'text');
input1.setAttribute('name', 'organizers[]');
obj.insertBefore(input1,null);
}
}
</script>
</head>
<body>
<div id="org"></div>
<select name="aaa" onchange="testClk()">
<option value="否" >否</option>
<option value="是" >是</option>
</select>
</body>
</html>
代码如上
我想实现的功能就是选择“是”以后,可以出现一个文本框,目前点击后没有反应
不太明白问题出在哪里了