
例如使用:jQuery做:
好了上代码:
<!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>
<script src=" http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<title>Untitled Page</title>
<script type="text/javascript">
$(document).ready(function() {
$("#inputNode").click(addrows)
})
function addrows() {
var trnode = $("<tr><td>自动增加</td></tr>")
trnode.appendTo($("#tabNode"))
}
</script>
</head>
<body>
<table id="tabNode" border="1" style=" border:red solid 1px">
<tr>
<td>自动增加</td>
</tr>
</table>
<input type="button" id="inputNode" value="点击创建"/>
</body>
</html>
这个用jquery来做更方便。
<!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" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<title>demo about table</title>
<script>
jQuery(function($){
//添加行
$("#add1").click(function(){
$("#table2>tbody").append('<tr><td></td><td><button onclick="deltr(this)">删除</button></td></tr>')
})
})
//删除行的函数,必须要放domready函数外面
function deltr(delbtn){
$(delbtn).parents("tr").remove()
}
</script>
</head>
<body>
<input type="button" name="add1" id="add1" value="新增1"/>
<table width="500" border="1" align="center" id="table2">
<tbody>
<tr>
<td>这行原来就有</td>
<td><button onclick="deltr(this)">删除</button></td>
</tr>
<tr>
<td>这行原来就有</td>
<td><button onclick="deltr(this)">删除</button></td>
</tr>
</tbody>
</table>
</body>
</html>
用法一<%
response.write "<table border=0 width=200>"
response.write "<tr><td><img border=0 src=这里必须是图片URL不能为变量></td></tr>"
response.write "<tr><td><img border=0 src=这里必须是图片URL不能为变量></td></tr>"
response.write "</table>"
%>
用法二
将图片地址存入IMG变量然后再下面调用
<%
img=" http://www.baidu.com/img/logo-yy.gif"
response.write "<table border=0 width=200>"
response.write "<tr><td><img border=0 src="&img&"></td></tr>"
response.write "<tr><td><img border=0 src="&img&"></td></tr>"
response.write "</table>"
%>用法三不把表格放在<%%>里
<%
……
img=" http://www.baidu.com/img/logo-yy.gif"
%>
<table border="0" width="200">
<tr>
<td><img border="0" src="<%=img%>"></td>
</tr>
<tr>
<td><img border="0" src="<%=img%>"></td>
</tr>
</table><%
……
%>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)