js动态添加标签和动态删除标签
2014-06-06 13:45
483 查看
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'createElement.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="<%=request.getContextPath() %>/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript">
$(function(){
$("#tianjia").click(function(){
var br=document.createElement("br");
var input=document.createElement("input");
var button=document.createElement("input");
input.type="file";
button.type="button";
button.value="移除...";
button.onclick=function(){
document.getElementById("tianjia11").removeChild(br);
document.getElementById("tianjia11").removeChild(input);
document.getElementById("tianjia11").removeChild(button);
}
document.getElementById("tianjia11").appendChild(br);
document.getElementById("tianjia11").appendChild(input);
document.getElementById("tianjia11").appendChild(button);
})
})
</script>
</head>
<body>
<div id="tianjia11">
<input type="file" >
</div>
<input type="button" value="添加" id="tianjia">
</body>
</html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'createElement.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="<%=request.getContextPath() %>/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript">
$(function(){
$("#tianjia").click(function(){
var br=document.createElement("br");
var input=document.createElement("input");
var button=document.createElement("input");
input.type="file";
button.type="button";
button.value="移除...";
button.onclick=function(){
document.getElementById("tianjia11").removeChild(br);
document.getElementById("tianjia11").removeChild(input);
document.getElementById("tianjia11").removeChild(button);
}
document.getElementById("tianjia11").appendChild(br);
document.getElementById("tianjia11").appendChild(input);
document.getElementById("tianjia11").appendChild(button);
})
})
</script>
</head>
<body>
<div id="tianjia11">
<input type="file" >
</div>
<input type="button" value="添加" id="tianjia">
</body>
</html>
相关文章推荐
- js 点击动态添加标签 删除指定标签
- JS点击动态添加标签、删除指定标签的代码
- js 动态添加标签(新增一行,其实很简单,就是几个函数的应用)
- js动态添加删除表格
- Js动态添加与删除Option对象
- js 动态新增、删除行 添加事件
- JS动态添加删除控件
- JS动态添加与删除select中的Option对象
- js动态添加标签(四)
- js动态添加删除,后台取数据
- JS中动态的添加和删除行及在后台获得动态添加行中的值
- JS动态添加删除控件
- js中加载并解析xml文件, 动态添加标签,控件
- JS动态添加删除控件
- [JS]动态添加删除ROW
- js动态添加删除table中的行
- JS动态添加删除<table>行
- JS动态添加删除表格
- js动态添加和删除一行
- js 对表格的动态操作(动态添加行,删除该行,在指定位置添加控件)