悬停链接的 jQuery setTimeout?
我有一个选项卡式脚本,它在悬停时切换选项卡。 由于链接靠得很近,我希望在触发悬停功能之前有一个延迟,因此当用户“触摸”其余链接时内容不会切换得那么快。
也许与 setTmeout 一起?这是我的脚本,我该怎么做?
$(".HotelPanel_content").hide(); //Hide all content
$("ul.HotelPanelNav li:first").addClass("active").show(); //Activate first tab
$(".HotelPanel_content:first").show(); //Show first tab content
$("ul.HotelPanelNav li").hover(function() {
$("ul.HotelPanelNav li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".HotelPanel_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("id"); //Find the rel attribute value to identify the active tab + content
$(activeTab).slideDown("slow"); //Fade in the active content
return false;
});
});
I am having a tabbed script which has switch tabs on hover.
Since links are close together, i want to have a delay before hover function is fired, so content is not switched so fast while user "touches" the rest of the links.
maybe with setTmeout? Here is my script, how do i do that?
$(".HotelPanel_content").hide(); //Hide all content
$("ul.HotelPanelNav li:first").addClass("active").show(); //Activate first tab
$(".HotelPanel_content:first").show(); //Show first tab content
$("ul.HotelPanelNav li").hover(function() {
$("ul.HotelPanelNav li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".HotelPanel_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("id"); //Find the rel attribute value to identify the active tab + content
$(activeTab).slideDown("slow"); //Fade in the active content
return false;
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
Try this:
也许你可以这样做
maybe you can do it this way
您可以将 .delay() 添加到任何 jquery 动画方法。此方法需要以毫秒为单位的时间,因此您可以在动画上执行此操作。
我相信你也可以延迟函数
Edit
你也可以使用 .timeout 函数
Edit 2
这对我来说很好用
You can add .delay() to any jquery animation method. This method takes a time in miliseconds so you could do this on the animation.
I believe you could also delay the function
Edit
You can also use the .timeout function
Edit 2
This work fine for me