JQuery animate() 函数延迟且运行缓慢
JQuery animate() function is delayed and runs slowly
当我调用 JQuery animate() 调用时,浏览器会延迟它 ~1 秒,然后运行得非常慢。
JQuery 代码:
<script type="text/javascript">
$(document).ready(function () {
$("#header").load("global/html/header.html",function(){});
$("#footer").load("global/html/footer.html",function(){});
$(".navLI").hover(function() {
$(this).animate({"backgroundColor": jQuery.Color(255, 51, 00, 255)}, 500);
$(this).animate({"borderLeftColor": jQuery.Color(255, 51, 00, 255)}, 500);
}, function () {
$(this).animate({"backgroundColor": jQuery.Color(255, 255, 255, 255)}, 500);
});
});
</script>
导入所有引用的库
视频: https://youtu.be/2NnDj_TGUNA
仅使用 CSS:
.navLI{
-webkit-transition: 0.3s;
transition: 0.3s;
background: rgba(255, 51, 255, 0.5);
}
.navLI:hover{
background: rgba(255, 255, 51, 1);
}
关于你的jQuery问题,你忘了使用.stop()
$(this).stop().animate({"backgroundColor": jQuery.Color(255, 51, 0, 1)}, 500);
相关文章:
- Xpath运行缓慢的查询
- 具有大型数据集的组件仅在 IE11/Edge 上运行缓慢
- 滚动事件运行缓慢-有没有更轻松的方法
- Html5画布动画在Android上运行缓慢
- JQuery animate() 函数延迟且运行缓慢
- 我的网站运行缓慢,我不知道为什么
- 为什么这段代码在火狐中运行缓慢
- Javascript 在加载 200mb 的新 Images() 后在 Safari / iPad2 中运行缓慢.为什么
- 在IE中导致“脚本运行缓慢”警告
- removeAllRanges在chrome/Alternatives中运行缓慢
- jQuery点击手柄在多次点击后运行缓慢
- html5/javascript游戏在ie8中运行缓慢
- jquery游戏在手机上运行缓慢
- Parse.Cloud在iOS上运行缓慢
- PrimeFaces”;此页面上的脚本导致Internet Explorer运行缓慢“;DataTable出错
- 当我使用这个时,浏览器运行缓慢
- 触发('click')导致“脚本运行缓慢,是否要停止它?”
- Gulp任务运行缓慢
- Angular-bootstrap -反复调用带有bootstrap工具提示的$compile会导致运行缓慢
- 在Mac OS X上运行缓慢