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>
上一篇:移动端触摸、点击事件优化(fastclick源码学习)


下一篇:Bzoj1901 Dynamic Ranking