The function named
that
is never called. Change function frame to
<!DOCTYPE html>
<html>
<style>
#myContainer {
width: 400px;
height: 400px;
position: relative;
background: yellow;
}
#thatFilm {
width: 40px;
height: 40px;
position: absolute;
background-color: red;
}
#oytu {
width: 40px;
height: 40px;
position: relative;
top:140px;
background-color: orange;
}
</style>
<body>
<script>
function wowThat()
{
var elem = document.getElementById("thatFilm");
var oydu = document.getElementById("oytu");
var epos = 0;
var opos = 0;
var id = setInterval(frame, 10);
function frame()
{
if (epos == 350)
{
clearInterval(id);
}
else
{
epos++;
elem.style.left = epos + 'px';
opos++;
if (opos == 140) {
opos = 40;
}
oydu.style.left = opos + 'px';
}
}
function that()
{
var oydu = document.getElementById("oytu");
if (elem.style.left = 140)
{
oydu.style.left = 40;
}
}
}
</script>
<p>
<button onclick="wowThat()">Click Me</button>
</p>
<div id ="myContainer">
<div id ="thatFilm"></div>
<div id ="oytu"></div>
</div>
</body>
</html>