Search code examples
jqueryfadefadeinout

jQuery fadein fadeout repeatedly


I have a image and in it wants to be fadein fadeout automatically when the document is loaded and it should be done till the document is closed .. help me plzz


Solution

  • this'll do it:

    $(function () {
        $('#fader').fadeIn('slow', function () {
            fadeItOut();
        });
    });
    
    function fadeItIn() {
        $('#fader').fadeIn('slow', function () {
            fadeItOut();
        });
    }
    
    function fadeItOut() {
        $('#fader').fadeOut('slow', function () {
            fadeItIn();
        });
    }
    

    with

    fader being the id of your image