我用js动态生成的单选框,用firefox浏览可以使用,但是用IE浏览时却无法选中不知道为什么
这是我的代码
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
window.onload = function()
{
for(var i = 0;i < 3;i++)
{
var form = document.getElementById("form");
var input = document.createElement("input");
input.setAttribute("type","radio");
input.setAttribute("name","answer");
if(i == 0)
{
input.setAttribute("checked",true);
}
form.appendChild(input);
}
}
</script>
</head>
<body >
<form id="form">
</form>
</body>
</html>
这是我的代码
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
window.onload = function()
{
for(var i = 0;i < 3;i++)
{
var form = document.getElementById("form");
var input = document.createElement("input");
input.setAttribute("type","radio");
input.setAttribute("name","answer");
if(i == 0)
{
input.setAttribute("checked",true);
}
form.appendChild(input);
}
}
</script>
</head>
<body >
<form id="form">
</form>
</body>
</html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
window.onload = function()
{
for(var i = 0;i < 3;i++)
{ var form = document.getElementById("form");
if(i == 0){ var input = document.createElement("<input type='radio' name='answer' checked>");
}else{
var input = document.createElement("<input type='radio' name='answer' >");
}
form.appendChild(input);
}
}
</script>
</head>
<body >
<form id="form">
</form>
</body>
</html>