我的脑袋估计被驴踢了,唉,下面请问大家很白痴的问题:
<html>
<head>
<script type="text/javascript">
function btnClick()
{
var input1= document.createElement("input");
input1.style.type="button";                 
          input1.style.value="动态按钮";
input1.onclick=function(){alert("我是动态创建的");};
document.body.appendChild(input1);
}
</script>
</head>
<body>
 <input type="button" value="btn" onclick="btnClick()"/>
</body>
</html>我是想动态生成一个按钮!为什么他会给我动态生成一个文本框!

解决方案 »

  1.   

    <html>
    <head>
    <script type="text/javascript">
    function btnClick()
    {
    var input1= document.createElement("input");
    input1.type="button";   
    input1.value="动态按钮";
    input1.onclick=function(){alert("我是动态创建的");};
    document.body.appendChild(input1);  
    }
    </script>
    </head>
    <body>
    <input type="button" value="btn" onclick="btnClick()"/>
    </body>
    </html>