简体   繁体   English

jQuery高亮显示新行上的效果

[英]Jquery highlight effect on new rows

I have an AJAX grid which refreshes every 60 seconds showing new rows. 我有一个AJAX网格,每60秒刷新一次,显示新行。 It's a very basic XMLHttpRequest() grid which pulls data from a php file. 这是一个非常基本的XMLHttpRequest()网格,它从php文件中提取数据。 I've checked all the internet but still haven't found a solution to how to implement this jQuery highlight effect on newly added rows after each refreshing: http://docs.jquery.com/UI/Effects/Highlight : 我已经检查了所有互联网,但是仍然没有找到在每次刷新后如何在新添加的行上实现此jQuery高亮效果的解决方案: http : //docs.jquery.com/UI/Effects/Highlight

What would be the best strategy? 最佳策略是什么?

Output new rows from your server with an extra class, say tohighlight . 用额外的类从服务器输出新行,例如tohighlight In your ajax success handler (in the JS), do something like: 在您的ajax成功处理程序(在JS中)中,执行以下操作:

...
success: function(data) {

  // ... your code to refresh the grid with new rows etc..

  // highlight new rows
  $('.tohighlight').highlight();

  // remove the tohighlight class, so these rows wont be highlighted after your next refresh
  $('.tohighlight').removeClass('tohighlight');

}
...

当您将数据包含在php文件中时,创建一个函数(仍在php文件中)即可将效果应用于数据,因此,当您从主页上将其拉出时,它已经具有效果。

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

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