jquery - 我的 jQuery animate() 运行了 2 次,如何解决这个问题?
问题描述
我用animate
jQuery的功能做了一些动画。当函数启动时,它运行 2 次;div 下降,上升,最后下降。
我不知道如何解决这个问题。
$("#p1 br").css("display","none");
$("#p12 br").css("display","none");
$("#p13 br").css("display","none");
$("#cryptosmart").mouseover(function() {
$("#cryptobox").animate({top: "1403.5px"});
$("#cryptopass").css("top","1591.5px");
});
$("#cryptosmart").mouseout(function() {
$("#cryptobox").animate({top: "1201px"});
$("#cryptopass").css("top","1389px");
});
$("#cryptobox").mouseover(function() {
$("#cryptopass").css("top","1591.5px");
});
$("#cryptobox").mouseout(function() {
$("#cryptopass").css("top","1389px");
});
解决方案
我不知道你的问题,因为我没有看到。你可以分享 jsfiddle/codepen 或堆栈片段吗?
但是你应该用 jQueryhover
函数试试这个。该函数可以使用两个参数。像这样;
$("#cryptosmart").hover(
function(){ //mouseenter
$("#cryptobox").animate({top: "1403.5px"});
$("#cryptopass").css("top","1591.5px");
},
function(){ //mouseleave
$("#cryptobox").animate({top: "1201px"});
$("#cryptopass").css("top","1389px");
}
);
推荐阅读
- django - Django 在多对多领域搜索
- python - 导入错误:无法从部分初始化的模块“matplotlib”导入名称“ft2font”
- vue.js - Vue:如何从秒开始计时?
- mongodb - MongoDB 4.0.12 使用 concat 更新嵌套数组
- google-apps-script - 如何获取谷歌电子表格的共享链接?
- html - jquery load() 或 innerHtml 不会将内容放在目标元素内
- amazon-web-services - Amazon Athena:如何一次删除所有分区
- javascript - 获取仅匹配直接前任的字符串
- angular - 检查空组并将其从数组中删除
- rabbitmq - MassTransit 中的连接事件与 RabbitMQ