<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.js"></script>
</head>
<body>
<table id="tb">
<tr id="show">
<td>111</td>
<td>111111</td>
</tr>
<tr id="hidden" >
<td>111</td>
<td>111111</td>
</tr>
<tr id="show">
<td>222</td>
<td>222222</td>
</tr>
<tr id="hidden" >
<td>222</td>
<td>222222</td>
</tr>
</table>
<div><input type="button" name="btn" id="btn" value="点我" /></div>
<script type="text/javascript">
$(document).ready(function(){
$("#tb tr").each(function(){
$(this).bind("click",function(){
var $tr = $("#tb tr:eq("+$(this).index()+")").clone(true);
//tr.appendTo("#tb tr").eq($(this).index());
$tr.insertAfter($("#tb tr:eq("+$(this).index()+")"));
//var evenTrId = $('#tb tr:even').attr("id");
//$('#tb tr:even').attr("id","hidden_"+evenTrId);
});
});
});
function cli(){
alert($('#tb tr:odd').length);
$('#tb tr:odd').each(function(){
alert($(this).attr("id"));
$(this).remove();
});
$("#tb tr").each(function(){
var $tr = $("#tb tr:eq("+$(this).index()+")").clone(true);
$tr.insertAfter($("#tb tr:eq("+$(this).index()+")"));
});
var evenTrId = $('#tb tr:odd').attr("id")
evenTrId = evenTrId.replace("show","hidden");
$('#tb tr:odd').attr("id",evenTrId);
$('#tb tr:odd').hide();
}
</script>
</body>
</html>
共同学习,写下你的评论
评论加载中...
作者其他优质文章