开发者

Hover effect on link

how to animate a pop-up only after the mouse has been over the link for a specific amount of 开发者_如何学编程time. Please help. Using 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);});


Hm, is suppose, you could do something like http://jsfiddle.net/mazzzzz/TJvSC/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜