Mar*_*ona 12 css jquery fadein
我试图淡化表格行的背景颜色,并且无法使其正确.点击按钮时会发生淡入.
我尝试过类似的东西:
$("#row_2").fadeIn('slow').css('background', 'gold')
Run Code Online (Sandbox Code Playgroud)
虽然这会将颜色应用于表格行,但它不会淡入,但会立即应用它.
我确信这是一件简单的事情,但我无法找到答案.我在这个网站上看了一遍,但是对于这个特定的东西仍然没有运气.
提前致谢
如果你还没有使用jquery UI,那么Peter Peller就是现货,至少要使用jQuery颜色插件.
下面是我掀起的代码片段,它在各种浏览器中取得了成功:
<a href="#" ID="fadeTable" title="click to fade col1">Click to fade Column 1</a>
<table width="400px" border="1" cellspacing="0" cellpadding="1"
summary="This is my test table">
<caption align="top">
My Caption
</caption>
<tr>
<th scope="col" class="row0 col1" >Col 1</th><th scope="col">Col 2</th>
</tr>
<tr>
<td class="row1 col1" >one</td><td>Uno</td>
</tr>
<tr>
<td class="row2 col1" >two</td><td>Dos</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
// requires http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js
var iAniSpeed = 2000;
var sBgColor = 'gold';
$('#fadeTable').click(function(){
$('td.col1').animate( { backgroundColor: sBgColor }, iAniSpeed);
return false;
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
作为替代方案,您可能希望首先将背景颜色设置为其原始颜色,然后设置为新颜色的动画.
要做到这一点,只需用以下内容替换当前的动画块:
$('td.col1').animate( { backgroundColor: 'white' }, 250, function()
{
$(this).animate( { backgroundColor: 'gold' }, 2000);
}
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19892 次 |
| 最近记录: |