How to move with buttons? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to move with buttons?

Can anyone tell me how to make a button move something in java script? Like for instant if i put "var = puppyPet" how do i make puppyPet move with ➡️⬅️⬆️⬇️ buttons?

24th Jan 2020, 5:56 PM
ℂ𝕙𝕣𝕚𝕤𝕥𝕪
ℂ𝕙𝕣𝕚𝕤𝕥𝕪 - avatar
1 Answer
+ 6
You could set the moving element position as absolute or relative and then change its left, right, bottom and top CSS properties through JavaScript in a function-handler for the button click event.
24th Jan 2020, 6:18 PM
SergeiRom