+ 8
How do i move the button please 😅
hey, So this is my first attempt at learning web and i come across 2 problems. my first problem is trying to position the function button central underneath the animation and my second problem is allowing the animation to finish before the function can be called. Thanks https://code.sololearn.com/W7t7FC5fc7sl/?ref=app
10 odpowiedzi
+ 13
Hey D_Stark I can help with the button position try this
button{
position:absolute ;
top:340px;
left:150px;
}
Running out to bike so if the other isn't solved when I get back happy to look at it for you. Best of Luck🙂
+ 10
Thanks glad that part worked for you I'm researching the second part still not certain but you might can try to add an event listener.
+ 10
Nice solution FreshScallops !!!🙂
+ 7
+ 6
bobbie works perfect thanks 😉👍
+ 6
FreshScallops thanks i will remember that next time 😉,i have updated the code and credited my helpers 😀👍
+ 5
FreshScallops that worked perfect thanks 😉👌
ODLNT your method worked with allowing the function to complete but when the function was called again the animation speed increased slightly each run 🤔
+ 2
Why not use the disabled attribute to disable and enable the button
function animation(){
var image = document.getElementById("ball");
document.getElementById("btn").disabled = true;
move = 0,sw = 0,timer = setInterval(sprite,21);
function sprite(){
if(move < 110 && sw ==0){
++move;
}
else{
++sw;
--move;
if(move===0){
document.getElementById("btn").disabled = false;
}
}//else
image.style.borderRadius = move+"px";
}//size
}//animation
make sure you add id="btn" to the button tag