-3

god day, I want to ask a question about the jQuery where it is possible to execute more than one event at the same time without waiting for the other process

as example :

<input type="button" id="btnSave" />
<script>

    $('#btnSave').click(function () {
        //... Do something
    });
    $('#btnSave').click(function () {
        //... Do something else
    });

</script>
Dina Diagovic
  • 611
  • 1
  • 5
  • 9
  • 2
    Can you describe what's inside those handlers that would make a difference? Give a concrete example of the effect you'd like, perhaps? – CertainPerformance Dec 02 '18 at 08:31
  • Event should be one, but runned functions two - simple. What is the problem to write few lines more in event initializer body? – Zydnar Dec 02 '18 at 08:33
  • if they should run in parallel that would imply they do not care about each-other, and that would imply paralleling them is irrelevant – vsync Dec 02 '18 at 08:34
  • i need do like Thread – Dina Diagovic Dec 02 '18 at 09:08
  • @CertainPerformance , i have idea to new library but i'm asked that is possibility to do this like Threads , and like jquery ajax a sync when true – Dina Diagovic Dec 02 '18 at 09:11
  • @Zydnar , i'm need to run two functions together i the same time not step by step – Dina Diagovic Dec 02 '18 at 09:52
  • Possible duplicate of https://stackoverflow.com/questions/9516900/how-can-i-create-an-asynchronous-function-in-javascript – Twisty Dec 03 '18 at 06:40
  • *As you may probably know, Javascript is single-threaded. To clarify better, this means that one single thread handles the event loop.* - https://medium.com/techtrument/multithreading-javascript-46156179cf9a – Twisty Dec 03 '18 at 06:44
  • @DinaDiagovic async functions, promises, sounds familiar? If not, just search for it. – Zydnar Dec 03 '18 at 09:58
  • @Twisty there are web workers for more threads and async functions. – Zydnar Dec 03 '18 at 09:58

1 Answers1

-1

Maybe you need this:

$('#btnSave').click(function () {
        function1();
        function2();
    });
shakogele
  • 409
  • 4
  • 14