Click Button | Sololearn: Learn to code for FREE!

+2

Click Button

I cant tell if this is working or not. what i mena is are my clicks working? I have a function for the same button but theyre are for different uses. Anyone know of anythinng is wrong with the code or am i paranoid i cant click my own button? https://code.sololearn.com/W2FE8G5Sh5MZ/?ref=app

6/2/2022 8:57:47 PM

Your Mom

26 Answers

New Answer

+3

You put the setInterval line inside the definition of the move function. Move it outside of it and remove the extra call to move that comes directly after and it works.

+1

Isn't it by design that you can't click the button? The moment the mouse cursor moves over the button the button jumps away, so of course you can't click it. However, on mobile, sometimes the button stops moving around and when that happens you can click it and the counter works.

+1

so should i add a transition to make it clickible?

+1

It depends on what your goal is. But if you want people to be able to click the button it can't move away before they have the chance to click it.

0

Why don't you just use the click event instead of mouse over? You can attach multiple function to an element/ event

0

so should i reorganize my javascript so you can click it first before ot moves?

0

You could use click events for both. Just make sure that you add clicker() before move() to the button

0

In case you are trying to do a game of catching the button, shouldn't the moving be primarily independent of the user's response? Like the button changing its position at random intervals when the player doesn't catch it?

0

hmm could work…good idea i can do that

0

okay, so im trying to make the button move while you have to try to click it but its not moving https://code.sololearn.com/WZiF88n1IQ2I/?ref=app

0

It does move. But just once at the start.

0

ye so how do i make it move infinetly? I used setInterval abd used math.random but its not working

0

Use a loop?

0

like a while loop?

0

Okay, I used a while loop but now nothings working. very confusing https://code.sololearn.com/WZiF88n1IQ2I/?ref=app

0

Your condition makes no sense. I'd try using an infinite loop using true as condition. But I don't have much experience with Javascript, so I'm not sure if that will work.

0

uhh..k so can u show me what im doing wrong and what type of loop i should be using

0

ye heres the original code https://code.sololearn.com/W2FE8G5Sh5MZ/?ref=app and heres what im trying to do: https://code.sololearn.com/WZiF88n1IQ2I/?ref=app

0

The original code interacts differently in a web browser opposed to this app. Have you tried it on desktop? To see the differences?

0

ye ye but i wanted the button to move infinetly while u chase it. thats why i sdded a setInterval so it moves every second