2012-05-24 57 views
1

我有一些样式的表。这就像:如何使用JQuery设置表格的背景颜色?

<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); 

但是,他们都没有工作。

你有什么建议?

+0

根据您的功能,您可能还需要添加悬停事件或点击事件。 –

回答

3

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得到它。

+0

也许为了清晰起见,您还应该提到代码不会更改。 –

+0

好的,它工作。我也可以在使用相同功能两次的动画之后将背景更改为旧颜色。 – Sercan

1

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