jquery延迟功能 [英] Jquery delay on function

查看:123
本文介绍了jquery延迟功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我为简单的淡入淡出菜单编写了两个jquery函数,它基本上将屏幕分成两半,并允许您转到两个站点之一。在这些功能工作之前,如何设置延迟时间2秒?这是我的代码:

  $('#retailNav')。bind({
mouseenter:function(){
$('#retailFull:not(:animated)')。fadeIn('slow');
$('#residentialNav:not(:animated)')。fadeOut('slow');
},
mouseleave:function(){
$('#retailFull')。fadeOut('slow');
$('#residentialNav')。fadeIn('slow ');
}
});
'('#residentialNav')。bind({
mouseenter:function(){
$('#retailHalf:not(:animated)')。fadeOut('slow');
$('#retailNav:not(:animated)')。fadeOut('slow');
$('#residentialFull p')。html('点击进入住宅');
$,
mouseleave:function(){
$('#retailHalf')。fadeIn('slow');
$('#retailNav')。fadeIn('slow' );
$('#residentialFull p')。html('Residential');
}
});

我是否有将它们包装到另一个函数中?

fade * delay()函数来解决方案 >调用或只是将所有内容封装到 setTimeout JS定时器中。


Hi I written a two jquery functions for a simple fading menu, it basically splits the screen in half and allows you go to one of two sites. How can I set a delay of say 2 seconds before these function work? Here's my code:

$('#retailNav').bind({
    mouseenter: function() {
        $('#retailFull:not(:animated)').fadeIn('slow');
        $('#residentialNav:not(:animated)').fadeOut('slow');
    },
    mouseleave: function() {
        $('#retailFull').fadeOut('slow');
        $('#residentialNav').fadeIn('slow');
    }
});
$('#residentialNav').bind({
    mouseenter: function() {
        $('#retailHalf:not(:animated)').fadeOut('slow');
        $('#retailNav:not(:animated)').fadeOut('slow');
        $('#residentialFull p').html('Click to enter residential');
    },
    mouseleave: function() {
        $('#retailHalf').fadeIn('slow');
        $('#retailNav').fadeIn('slow');
        $('#residentialFull p').html('Residential');
    }
});

Do I have somehow wrap these in another function?

解决方案

You can use delay() function before your fade* calls or just wraps everything into setTimeout JS timer.

这篇关于jquery延迟功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆