How do I separate functionality with Javascript code to set Timeout?

Posted by GIVE-ME-CHICKEN on Stack Overflow See other posts from Stack Overflow or by GIVE-ME-CHICKEN
Published on 2014-06-05T09:00:53Z Indexed on 2014/06/05 9:25 UTC
Read the original article Hit count: 182

Filed under:
|

I have the following code:

var comparePanel = $(__this.NOTICE_BODY);
        clearTimeout(__this._timeout);
        comparePanel.addClass(__this.VISIBLE);
        __this._timeout = setTimeout(function () {
            comparePanel.removeClass(__this.CL_VISIBLE);
        }, 3000); 
    }
})

The following has been repeated a few times:

__this._timeout = setTimeout(function () {
            comparePanel.removeClass(__this.CL_VISIBLE);
        }, 3000);

I want to be able to do something like this:

__this._timeout = setTimeout(comparePanel, 3000);

How do I define and call that function?

PS. I am very very new to JavaScript so any explanation of what is going on is greatly appreciated.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery