<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body> <table id="tableId" class="123">
<tr >
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td><button>删除</button></td>
</tr>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
<td>d</td>
<td><button>删除</button></td>
</tr>
<tr>
<td>e</td>
<td>f</td>
<td>g</td>
<td>h</td>
<td><button>删除</button></td>
</tr>
<tr>
<td>i</td>
<td>j</td>
<td>k</td>
<td>l</td>
<td><button>删除</button></td>
</tr> </table> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
window.onload=function() { $("table td button").click(function () {
var row = $(this).parent().parent().index(); // 行位置
console.log("当前行", row);
var allnum = $("table").find("tr").length; //获取总共有多少tr
console.log("all", allnum); for (i = allnum; i >= row; i--) {
if (i == allnum) {
last_index = allnum - 1;
console.log("最后一个", last_index);
$("table tr:eq(" + last_index + ")").remove(); }
else {
console.log("----", i);
$("table tr:eq(" + i + ")").remove(); };
};
}); }
</script>
</body>
</html>

  

最新文章

  1. spring整合mybatis使用&lt;context:property-placeholder&gt;时的坑
  2. [LeetCode] Climbing Stairs 爬梯子问题
  3. How to build .apk file from command line(转)
  4. python 学习笔记7 面向对象编程
  5. 【PC网站前端架构探讨系列】结合公司网站首页,谈前端模块化开发与网站性能优化实践
  6. 用eclipse碰到的一些错误,然后自己去网上找的解决办法
  7. 一文让你彻底了解iOS字体相关知识
  8. 1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
  9. 微软职位内部推荐-Senior Software Engineer -Web
  10. SQL和NOSQL有区别吗?
  11. Xamarin IOS – hello word
  12. Cocos2d Lua 越来越小样本 内存游戏
  13. 第 1 章 Node.js 介绍
  14. Java 基础 JRE和JDK的区别
  15. Python机器学习(基础篇---监督学习(支持向量机))
  16. .net MVC使用NPOI读取Excel模板,再写入数据
  17. web中的集群与分布式
  18. TWebBrowser禁止弹出Alert对话框
  19. c#异步等待
  20. Linux常用rmp包网址

热门文章

  1. Spring Boot2 系列教程 (八) | 配置日志
  2. dubbo配置文件解读(2)
  3. playbooks框架部署远程主机
  4. 【新书推荐】《ASP.NET Core微服务实战:在云环境中开发、测试和部署跨平台服务》 带你走近微服务开发
  5. [UVA1494] Qin Shi Huang&#39;s National Road System
  6. java面试| 线程面试题集合
  7. azure 第一弹
  8. Spring Cloud Alibaba 之 Sentinel 限流规则和控制台实例
  9. Navicat premium 12 for mac 无限试用
  10. SpringBoot缓存篇Ⅰ--- 缓存抽象