Javascript 创建动态input

Javascript 创建动态input
<%@ page language="java"  import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>js run</title>
    </head>
    <script type="text/javascript">
function createForm(){
     var div3=document.getElementById("div1");
     var a=document.createElement("input");
     a.type="text";
     a.value="测试1";
     var c=document.createElement("br");
     var b=document.createElement("input");
     b.type="text";
     b.value="测试2";
     var Object=div3.appendChild(a);
     var Object=div3.appendChild(c);
     var Object=div3.appendChild(b);
}
</script>
    <body>
        <input type="button" value="创建input" onclick="createForm()" />
        <br>
        下面就是要创建的输入框
        <br>
        <div id="div1">
            

        </div>
        <br>
        333
    </body>
</html>

你可能感兴趣的:(Javascript 创建动态input)