简体   繁体   English

setTimeout函数

[英]setTimeout function

I've been researching my problem and don't want to post a duplicate but I have tried the methods as described in my research and cannot get my function to delay!! 我一直在研究问题,不想重复,但是我尝试了研究中描述的方法,无法延误我的功能!!

Can someone take a look and let me know if there is something wrong with my syntax and why it's not functioning? 有人可以看一下,让我知道我的语法是否有问题以及为什么它不起作用吗? Everything runs good except for the setTimeout function 除了setTimeout函数,其他一切运行良好

$(document).ready(function(){   
    $("#slider").easySlider({
        auto: true, 
        continuous: true
    });

    $("#prevBtn a").hide();
    $("#nextBtn a").hide();
    $("#slider").mouseover(function(){
        $("#prevBtn a").show();
        $("#nextBtn a").show();
    });

    setTimeout(function(){
        $("#prevBtn a").fadeOut('slow');
        $("#nextBtn a").fadeOut('slow');
    },3000);
});
$(document).ready(function(){   
    $("#slider").easySlider({
        auto: true, 
        continuous: true
    });

    $("#prevBtn a").hide();
    $("#nextBtn a").hide();
    $("#slider").mouseover(function(){
        $("#prevBtn a").show();
        $("#nextBtn a").show();
    })
    .mouseout(function(){

        setTimeout(function(){
            $("#prevBtn a").fadeOut('slow');
            $("#nextBtn a").fadeOut('slow');
        },3000);

    });

});

Your setimeout function works. 您的setimeout函数起作用。 I put a 我把

console.log('hi');

inside and i saw it. 在里面,我看到了。

I think you need to remove these lines, because it will make the element hidden on dom ready. 我认为您需要删除这些行,因为这会使元素隐藏在dom上。

$("#prevBtn a").hide();
$("#nextBtn a").hide();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM