1

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

$(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);
});
6
  • Can you setup a demo in jsfiddle? Commented Jan 9, 2013 at 2:06
  • Your setimeout function works. I put a console.log('hi') inside and i saw it. Commented Jan 9, 2013 at 2:06
  • 4
    You're hiding #prevBtn a and #nextBtn a and then fading them out in setTimeout, you probably meant to use fadeIn (api.jquery.com/fadeIn) Commented Jan 9, 2013 at 2:07
  • I don't want the buttons to show on load that's why I have them hidden on load. When the user mouseover the slider the buttons then appear. On mouse out I would like the buttons to fade out after 3 seconds.. Commented Jan 9, 2013 at 2:12
  • .delay only works for 1.4. I'm not using that Commented Jan 9, 2013 at 2:16

2 Answers 2

4
$(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);

    });

});
Sign up to request clarification or add additional context in comments.

2 Comments

Agreed. I didn't try to optimize at all because we don't know what his html looks like.
Hi Geuis. Your solution did the trick. I could not find that anywhere in my research. Thank you and everyone for your help. :)
1

Your setimeout function works. 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.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.