【发布时间】:2025-11-21 19:15:02
【问题描述】:
我对 jQuery 很陌生。我创建了一个小脚本来为循环中的 DIV 的颜色背景和另一个 DIV 的边框颜色设置动画。 我使用了 jquery color 插件并且脚本有效! (难以置信)
问题是我的脚本非常慢,而且页面加载有问题(尤其是 IE) 这是脚本:
<script type="text/javascript">
$(document).ready(function() {
spectrum();
function spectrum(){
$('#rt-main').animate( { backgroundColor: "#aeff00" }, 5000);
$('#rt-main').animate( { backgroundColor: "#ff6c00" }, 5000);
$('#rt-main').animate( { backgroundColor: "#0086b6" }, 5000);
$('#rt-main').animate( { backgroundColor: "#00a4a8" }, 5000);
$('#rt-main').animate( { backgroundColor: "#d43795" }, 5000);
$('#rt-main').animate( { backgroundColor: "#ffd200" }, 5000);
$('#rt-header').animate( { borderTopColor: "#aeff00" }, 5000);
$('#rt-header').animate( { borderTopColor: "#ff6c00" }, 5000);
$('#rt-header').animate( { borderTopColor: "#0086b6" }, 5000);
$('#rt-header').animate( { borderTopColor: "#00a4a8" }, 5000);
$('#rt-header').animate( { borderTopColor: "#d43795" }, 5000);
$('#rt-header').animate( { borderTopColor: "#ffd200" }, 5000);
spectrum();
}
});
</script>
我确信有更好的方法来做同样的事情。 在这里你可以看到一个演示。 (不适用于 IE)
【问题讨论】:
标签: jquery colors background jquery-animate jquery-color