Stop function javascript | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 6

Stop function javascript

I would like to stop function if user click on a button. I know there is 'return' but it does nothing... function abc () { $('.stop').click (function () { return; }); } $('.start').click (function() { abc (); }); example : how to stop the abc function after the user click to .start and decided to click to .stop ?

21st Oct 2017, 10:11 AM
NoxFly
NoxFly - avatar
4 Respostas
+ 5
Use jquery .on() and .off() functions to add or remove an event handler.
21st Oct 2017, 11:14 AM
CalviÕ²
CalviÕ² - avatar
+ 5
Unless abc is in a setInterval function, it should be pointless to stop a function which would take a fraction of second to be executed
21st Oct 2017, 10:19 AM
Dapper Mink
Dapper Mink - avatar
+ 4
en fait t'as un menu, si tu click sur -easy : Ƨa fait cette fonction. une fois la game terminĆ©e Ƨa te demande 'restart' ou 'menu' si tu reviens dans menu et que cette fois tu choisis 'medium', Ƨa executera pas la mĆŖme fonction. mais Ƨa continue Ć  exexuter la fonction 'easy'... faut que je fasse UNE seule fonction avec un Switch {} dedans ?
21st Oct 2017, 10:27 AM
NoxFly
NoxFly - avatar
+ 4
Pas obligatoirement Tu peux changer la difficultƩ avec seulement des variables par exemple Mais pour stopper la fonction j'aurais besoin d'en savoir plus sur la structure de ton code dƩsolƩ
21st Oct 2017, 10:34 AM
Dapper Mink
Dapper Mink - avatar