[英]FadeIn with css?
<textarea id="text" rows="5" cols="25"></textarea> <span id="fade">fade</span>
$("#fade").click(function () {
$("#text").fadeIn(31000, function () {
$("#text").css('background-color', 'red');
});
return false;
});
http://jsfiddle.net/tG7xE/ http://jsfiddle.net/tG7xE/
Why in this example fadeIn doesnt working? 为什么在此示例中,fadeIn无法正常工作? How can i make it? 我该怎么做?
http://jsfiddle.net/tG7xE/5/ http://jsfiddle.net/tG7xE/5/
<textarea style="display:none;" id="text" rows="5" cols="25"></textarea> <span id="fade">fade</span>
$("#fade").click(function () {
$("#text").fadeIn(function () {
$("#text").css('background-color', 'red');
});
return false;
});
fadeIn
works only if element is not visible to hide it use fadeOut()
or hide()
. 只有当元素不可见才能使用fadeOut()
或hide()
将其隐藏时, fadeIn
起作用。
I do think you expect to work fadeIn
differently from what it actually does. 我确实认为您希望fadeIn
与实际工作fadeIn
不同。 It's not used to fade in the background color, but to fade in a hidden element. 它不用于淡化背景颜色,而用于淡化隐藏的元素。 In case you set your textarea
's display
to none
(like in: http://jsfiddle.net/tG7xE/4/ ) you'll see what I mean. 如果将textarea
的display
为none
(例如: http : //jsfiddle.net/tG7xE/4/ ),您将明白我的意思。 After the fadeIn is complete the specified callback is executed (bg turns red). 在fadeIn完成后,将执行指定的回调(bg变为红色)。
In case you want to animate background colors I think you should have a look at jQuery UI's possibilities to animate color values: http://jqueryui.com/demos/animate/ 如果您想设置背景颜色的动画,我认为您应该看看jQuery UI可以设置颜色值的动画: http : //jqueryui.com/demos/animate/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.