I'm looking for a way to do the following.

I add a <div> to a page, and an ajax callback returns some value. The <div> is filled with values from the ajax call, and the <div> is then prepended to another <div>, which acts as a table column.

I would like to get the user's attention, to show her/him that there is something new on the page.
I want the <div> to blink, not show/hide, but to highlight/unhighlight for some time, lets say 5 seconds.

我一直在看blink插件,但据我所知,它只在元素上显示/隐藏.

Btw, the solution has to be cross-browser, and yes, IE unfortunately included. I will probably have to hack a little to get it working in IE, but overall it has to work.

推荐答案

jQuery UI Highlight Effect是你要找的.

$("div").click(function () {
      $(this).effect("highlight", {}, 3000);
});

文档和演示可以在here页找到


Edit:


Edit #2:
要调整不透明度,可以执行以下操作:

$("div").click(function() {
  // do fading 3 times
  for(i=0;i<3;i++) {
    $(this).fadeTo('slow', 0.5).fadeTo('slow', 1.0);
  }
});

...so it won't go any lower than 50% opacity.

Jquery相关问答推荐

将选定2个AJAX结果显示到模板中

用 JS 触发 CSS 悬停

SCRIPT7002:XMLHttpRequest:网络错误 0x2ef3,由于错误 00002ef3 无法完成操作

Google Maps API v3 infowindow 关闭事件/回调?

如何在单击时 Select 多选 Select 框的所有选项?

如何使用jQuery找到元素顶部的垂直距离(以px为单位)

当有多个具有相同 ID 值的元素时,jQuery 是如何工作的?

可以在删除类时反转css动画吗?

jQuery 判断 是否存在并且有一个值

在不使用提交按钮的情况下触发标准 HTML5 验证(表单)?

JQuery .hasClass 用于 if 语句中的多个值

如果 iframe src 无法加载,则捕获错误.错误:-拒绝在框架中显示 'http://www.google.co.in/'..

动态创建并提交表单

如何将数组传递给 jQuery .data() 属性

jQuery: Select 不为空的数据属性?

jQuery或javascript查找页面的内存使用情况

jQuery 发送字符串作为 POST 参数

请求的资源错误中不存在Access-Control-Allow-Origin标头

使用 jQuery Select 空文本输入

如何在 ReactJS 中使用 JQuery