码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-03-13 18:40:01      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

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

<!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>

 

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

标签:

原文地址:http://www.cnblogs.com/sunxun/p/4335680.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!