![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
使用javascript 加上两个按钮,实现动态添加和删除表格操作
<%@pagelanguage="java"pageEncoding="utf-8"%><%@tagliburi="http://java.sun.com/jsp/jst...
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/adminStyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
<strong>产品类型</strong><br />
<hr size="1" /><br />
<br />
<!-- <input type="button" value="修改" onclick="window.location.href='editarticle.html'" /> -->
<table width="100%" cellpadding="3" cellspacing="1" border="0" bgcolor="#CCCCCC">
<tr bgcolor="#72B7D9" height="20">
<th align="center" width="80">类别名称</th>
<th align="center" width=14%>操作</th>
</tr>
<c:forEach items="${productList}" var="link">
<tr bgcolor="#F5F5F5" onmouseover="this.bgColor='#E5E5E5'" onmouseout="this.bgColor='#F5F5F5'" >
<td width="80" align="center">${link.name}</td>
<td width="130" align="center"><a href='operateProductType?id=${link.id}&type=1'>查看</a> <a href='operateProductType?id=${link.id}&type=2'></a></td>
</tr>
</c:forEach>
</table>
<% } %>
</body>
</html> 展开
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/adminStyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
<strong>产品类型</strong><br />
<hr size="1" /><br />
<br />
<!-- <input type="button" value="修改" onclick="window.location.href='editarticle.html'" /> -->
<table width="100%" cellpadding="3" cellspacing="1" border="0" bgcolor="#CCCCCC">
<tr bgcolor="#72B7D9" height="20">
<th align="center" width="80">类别名称</th>
<th align="center" width=14%>操作</th>
</tr>
<c:forEach items="${productList}" var="link">
<tr bgcolor="#F5F5F5" onmouseover="this.bgColor='#E5E5E5'" onmouseout="this.bgColor='#F5F5F5'" >
<td width="80" align="center">${link.name}</td>
<td width="130" align="center"><a href='operateProductType?id=${link.id}&type=1'>查看</a> <a href='operateProductType?id=${link.id}&type=2'></a></td>
</tr>
</c:forEach>
</table>
<% } %>
</body>
</html> 展开
1个回答
展开全部
最简单的方法,在你需要添加表格的地方,弄个Div,将你要添加的表格使用InnerHtml的方式直接扔到div里面去,点击删除的话,再从Div里面移除出去就是了,如果不喜欢的话,还有CreateElement的方法可以使用都可以实现你的目的。不过有个问题就是,你要动态添加表格的话,可以添加多少个?
如果是多个的话,你那个删除按钮怎么处理,你需要删除的东西,需要考虑清楚啊
如果是多个的话,你那个删除按钮怎么处理,你需要删除的东西,需要考虑清楚啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询