How to call a function in jquery?

I have:

(function( $ ){

    $.fn.fade = function(options) {
        var settings = {
            'speed': 5000
        if ( options ) {
            $.extend( settings, options );

        var tickerIndex = 0;
        var tickerRef = this;
        function fadeOut() {
            var ticker = tickerRef.children().eq(tickerIndex);
            ticker.css("display", "block");
            //var node = document.getElementById([i];

            ticker.fadeOut(settings.speed, function () {

                //var node = document.getElementById(this).childNodes[i];
                ticker.css("display", "none");

                if (tickerIndex == tickerRef.children().length) {
                    tickerIndex = 0;
})( jQuery );

I want to change fadeOut() to setTimeout(‘fadeOut()’, 10000) but it says fadeOut() is undefined. How should I call it?


jQuery has a method you can use called delay(), basically you use it like any other method but it does the same thing as calling a setTimeout() function manually.


Is this how it is done?



It doesn’t work. Please help. Thanks

The delay method needs to be declared before the fadeOut method, see the below example.


Sorry Chris, I think you got me wrong.

I want the fadeOut() at lines 3 and 6 from the bottom of the code to call fadeOut() at a delay of 10000milisecs. Not a $(‘div’).

How should I call it? Thanks.

setTimeout(function() { fadeOut(); }, 10000);


setTimeout(fadeOut, 10000);

(both do the same thing, but I personally prefer the syntax of the former)


sorry…it says fadeOut() is undefined.