日期:2014-05-16 浏览次数:20401 次
//删除<tr/>
var deltr =function(index)
{
var _len = $("#tab tr").length;
$("tr[id='"+index+"']").remove();//删除当前行
for(var i=index+1,j=_len;i<j;i++)
{
//var nextTxtVal = $("#desc"+i).val();
var nextTxtVal = $("#desc"+i).html();
var nextIndex = $("#desc"+i).get(0).selectedIndex;
$("tr[id=\'"+i+"\']")
.replaceWith("<tr id="+(i-1)+" align='center'>"
+"<td>"+(i-1)+"</td>"
+"<td><select name=ColorName"+(i-1)+" id='desc"+(i-1)+"' style=width:auto;>"+nextTxtVal+"</select></td>"
+"<td><a href=\'#\' onclick=\'deltr("+(i-1)+")\'>删除</a></td>"
+"</tr>");
$("#desc"+(i-1)).get(0).selectedIndex = nextIndex; //index为索引值
}
<!-- include file="public/isuser.asp" -->
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<title></title>
<script>
$(document).ready(function(){
//<tr/>居中
$("#tab tr").attr("align","center");
//增加<tr/>
$("#but").click(function(){
var _len = $("#tab tr").length;
//alert(_len);
$("#tab").append("<tr id="+_len+" align='center'>"
+"<td>"+_len+"</td>"
&