1
My goal was to run one function at a time, but my functions that move the square are running together and I don’t know how to make one run only after the other ends Here’s the code:
css:
#caixa1{
width: 200px;
height: 200px;
background: green;
position: relative;
}
#caixa2{
width: 50px;
height: 50px;
background: red;
position: absolute;
}
html:
<body>
<div id="caixa1">
<div id="caixa2">
</div>
</div>
</body>
javascript:
var posH = 0
var posL = 0
var caixinha = document.getElementById("caixa2")
var intervaloL = setInterval(movL,10)
var intervaloH = setInterval(movH,10)
//left = ir pro lado direito
//top = vai pra baixo
function movL()
{
if(posL >= 150)
{
caixinha.style.left = posL +'px'
}else{
posL += 1
caixinha.style.left = posL + "PX"
}
}
function movH()
{
if(posH >= 150)
{
caixinha.style.top = posL +'px'
}else{
posH += 1
caixinha.style.top = posH + 'px'
}
}
I couldn’t understand no. What do you intend to do?
– Sam
I don’t understand what you want to do, but take a look at callback
– Giovanni Dias
I want to run one function at a time, :/
– 0000FFcar
dei uma editada espera que de para entender esta vez, :/
– 0000FFcar