Search code examples
javascriptlivejquery

What jQuery method do I put here if I want it to be triggered right when the page is loaded?


What do I replace the question marks with if I want the class to be added when the page is loaded?

$("form#signupform input#email").live("????", function() {
    $(this).addClass("launchrock");
});

Solution

  • You'd replace more than that.

    $(window).load(function() {
        $("form#signupform input#email").addClass("launchrock");
    });
    

    Assuming by page you mean page with all assets; if not, use $(function() { ... }) which only waits for the DOM API to be ready for use.