1

My code has the following button:

<input type="submit" id="btnEnviar" name="btnEnviar" value="Enviar">

And in the JavaScript I've got this function:

$('#btnEnviar').click( function(){ });

I need to know to use two functions using the same button id "btnEnviar", and event ".click".

For example:

$('#btnEnviar').click( function(1){ });
               .click( function(2){ });
2
  • 1
    Why can't it all go in the same click event? Commented Mar 30, 2015 at 23:44
  • See this jsFiddle. Commented Mar 30, 2015 at 23:49

1 Answer 1

3

Just call both functions in the handler:

$("#btnEnviar").click(function() {
    function1();
    function2();
});

or bind multiple handlers:

$("#btnEnviar").click(function1).click(function2);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.