【问题标题】:How can I animate the background color of a table using JQuery?如何使用 JQuery 为表格的背景颜色设置动画?
【发布时间】:2017-10-11 03:04:23
【问题描述】:

我有一张带有一些样式的桌子。就像:

<table class="table_design" id="cart">
   <tr>
       <td>something</td>
       <td>something else</td>
   </tr>
</table>

我试过了:

$("#cart").animate({backgroundColor: '#FF0000'}, 'slow');

$("#cart").effect("highlight", {}, 3000);

但是,它们都不起作用。

你有什么推荐的?

【问题讨论】:

  • 您可能还想添加悬停事件或单击事件,具体取决于您的功能。

标签: jquery animation html-table effect


【解决方案1】:

jQuery UI 包含到您的项目中,并使用.animate 方法will animate colors

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.20/jquery-ui.min.js"></script>

您可以从MicrosoftGoogle 托管的CDN 获取它。

【讨论】:

  • 也许为了清楚起见,您还应该提到代码不会改变。
  • 好的,成功了。我还可以在动画后使用相同的函数两次将背景更改为旧颜色。
【解决方案2】:

你需要 jquery-ui 在背景颜色上做动画。 fiddle

【讨论】:

    猜你喜欢
    • 2012-10-06
    • 2016-01-02
    • 2022-12-23
    • 1970-01-01
    • 2011-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多