日期:2014-05-16 浏览次数:20343 次
var butt = document.createElement('<input type="button" name="tt" value="test">'); // IE下name属性需要直接指定
<html>
<head>
<title>test</title>
<script language="javaScript">
function test()
{
//document.getElementById("dis").disabled = true;
var butt = document.createElement("<input>");
butt.setAttribute("type","button");
butt.setAttribute("value","test");
butt.setAttribute("name","tt");
butt.setAttribute("id","tt");
document.body.appendChild(butt);
}
function getButtonName()
{
var ttt = document.getElementsByName("tt");
alert("ttt = " + ttt.length);
}
</script>
</head>
<body>
<input type="button" id="dis" value="dis" onclick="getButtonName();"/>
<input type="button" value="test" onclick="test();"/>
</body>
</html>