gpt4 book ai didi

javascript - 链接悬停效果

转载 作者:太空宇宙 更新时间:2023-11-04 16:24:51 25 4
gpt4 key购买 nike

如何仅在鼠标悬停在链接上特定时间后才为弹出窗口设置动画。请帮忙。使用 Jquery.????

最佳答案

//Here is my trial
//create a global var called canShow that will be set to true
//as the mouse is over the cursor, and then reset when the mouse moves away.
//then use timeout to display the popup after some interval
//as long as the canShow hasn't been reset to false.

var canShow = false;
var desiredTimeOut = 2000; //in milliseconds
var intervalId;

//assume our link has id 'linkId'
//we'll use jquery since you tag with it
$('#linkId').hover(function(){
canShow = true;
intervalId = setTimeout(function() {
if(canShow == true) $('#myPopupId').show();
}, desiredTimeOut);

}).mouseout(function() { canShow = false; clearInterval(intervalId);});

关于javascript - 链接悬停效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5775318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com