悬停对链接的影响

时间:2011-04-25 05:00:01

标签: javascript jquery html css

仅在鼠标经过链接一段特定时间后才能为弹出窗口设置动画。请帮忙。使用Jquery。????

2 个答案:

答案 0 :(得分:1)

//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);});

答案 1 :(得分:0)

嗯,假设你可以做http://jsfiddle.net/mazzzzz/TJvSC/

之类的事情
相关问题