简体   繁体   English

如何使用jQuery查找HTML表的最新修改(新添加或更改)行

[英]how to find the latest modified(newly added or changed) row of html table using jquery

如何查找html表的最新修改(新添加或更改)行。

Plain way to achieve this by maintaining a flag in latest row. 通过在最新行中保留一个标志来实现此目的的简单方法。

let's say flag-name/class-name = "latest" 假设flag-name / class-name =“ latest”

1) Remove all row with flag/class name latest 1)删除所有带有最新标志/类名称的行

$('#resultTable tr').removeClass("latest");

2) when you add a new row add latest class to it 2)当您添加新行时,向其添加最新类

let's say newly added/modified row id is row1 假设新添加/修改的行ID为row1

$('#row1').addClass("latest");

you can get the latest row by calling. 您可以通过致电获取最新的行。

var latest = $('.latest')[0];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM