我在JQuery上有以下函数来显示我的工具提示,但是当我尝试添加超时以在显示工具提示之前做出一些延迟没有任何作用(((
$('.help').mouseover(function(){
setTimeout(function{ //this is timeout if i delete this - evrthng goes well
$(this).find('div').stop().fadeIn(900);
var top = $(this).position().top;
var left = $(this).position().left;
var height = $(this).find(".tip").height();
$(this).find(".tip").css('top', top-height);
$(this).find(".tip").css('left', left)
}, 1000);
});
Run Code Online (Sandbox Code Playgroud)
请告诉我,我做错了什么?
里面setTimeout(),this指的是Window代替$('.help').试试这个:
$('.help').mouseover(function(){
var that = this;
setTimeout(function() {
$(that).find('div').stop().fadeIn(900);
var top = $(that).position().top;
var left = $(that).position().left;
var height = $(that).find(".tip").height();
$(that).find(".tip").css('top', top-height);
$(that).find(".tip").css('left', left)
}, 1000);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40 次 |
| 最近记录: |