+ 3

How do I get one onclick event to override another?

Please can someone help me, I'm trying to make the circle move the direction of whichever arrow key is clicked but if you hit up then right, it does both and I want it to cancel out the other buttons.. Also Idk how to make the object stay in its new position rather than go back to the middle if anyone can help me with that too 🙏 Please explain like I'm 5, my knowledge is basic 😂 https://code.sololearn.com/WBitrfPnaFpf/?ref=app https://code.sololearn.com/WBitrfPnaFpf/?ref=app

27th Sep 2020, 5:25 PM
Leia Bishop
Leia Bishop - avatar
7 ответов
+ 4
https://www.codeproject.com/Questions/469411/using-document-onclick-overrides-other-onclick-eve
27th Sep 2020, 7:50 PM
Bhargava Ram
Bhargava Ram - avatar
27th Sep 2020, 8:21 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 3
Bhargava Ram Ai.dz Jayakrishna🇮🇳 thank you all that is very helpful I think I get it now ❤️
28th Sep 2020, 1:35 PM
Leia Bishop
Leia Bishop - avatar
+ 2
Leia Bishop You global variables for pos and box. Declare those before function definition.. Local variables defining new one every time you click on..
27th Sep 2020, 7:02 PM
Jayakrishna 🇮🇳
+ 1
Leia Bishop first you need a right function, which the same as left and u just use pos+=1 instead of pos-=1
27th Sep 2020, 6:05 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 1
Ai.dz i didn't get as far as to write the last two buttons because I couldn't get left to override up
27th Sep 2020, 7:02 PM
Leia Bishop
Leia Bishop - avatar
+ 1
You're welcome..
28th Sep 2020, 1:36 PM
Jayakrishna 🇮🇳