javascriptjquery

How can I call a JQuery function?


Ok, this is like two question in one!

  1. Why is this JQuery function call failing? or how should I call the JQuery function? Firebug tells me that $('#login').slideup is not a function.

    setTimeout("$('#login').slideup('slow');",2000);

  2. How can I declare a JQuery function externally (not binding it to anything and not after document().ready() then later call it in my javascript functions?

For example:

function afterLogin(){
  $('#login').slideup('slow');
}

then later call it as:

setTimeout('afterLogin();',2000)

Solution

  • for the first part you can do

    setTimeout(function(){$('#login').slideUp('slow');},2000);
    

    the second part can be done exactly the same:

    function afterLogin(){ $('#login').slideUp('slow'); }
    

    then later call it as:

    setTimeout(afterLogin,2000);
    

    edit: fixed the casing from slideup to slideUp