JS 通过点击事件动态添加文本框

直接拷贝到浏览器就能实现

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Change.html</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
     
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  <script language="javascript">
     function test4(event) {
       if(event.value == "11") {
		  var div3 = document.getElementById("div3"); 
		  div3.innerHTML ="<form><input type='text' name='s' value='xx'></form>";
       }
       if(event.value == "22") {
          var div3 = document.getElementById("div3"); 
		  div3.innerHTML ="";
       }
     }
  </script>
</head>
<body>
 <input type="text" id="div2" value=""/>
  <div id="div3"></div>
  <input type="button" value="11" onclick="test4(this)"/>
  <input type="button" value="22" onclick="test4(this)"/>
 
  </body>
</html>

 

posted on 2015-03-13 17:41  手撕高达的村长  阅读(2279)  评论(0编辑  收藏  举报

导航