Search code examples
functioncallconventions

How to call .on('click') function from another function in JavaScript


I have two functions, first $('#tabela').on('click', '.buyButton', function() and second function submitAll() How can I call first function from the second?


Solution

  • This will do

    First function

    function first() {
        $('#tabela').on('click', '.buyButton', function() {});
    }
    

    In Second function:

    function submitAll() {        
        first();     
    }
    

    If #tabela is a button then use onClick="first();"