Loading...
Обучение/Помощь новичкам | Помогите, как сделать перемещение картинки влево,
Holter (25.06.2017 в 18:44)
Master zpank , можно код?)

----JS----
<script>
function car_down () {
x = 0;
x = document.getElementById("moto").offsetTop;
xn = x + 50;
document.getElementById("moto").style.top = xn+"px"
}
function car_up () {
x = 0;
x = document.getElementById("moto").offsetTop;
xn = x - 50;
document.getElementById("moto").style.top = xn+"px"
}
function car_left () {
x = 0;
x = document.getElementById("moto").offsetLeft;
xn = x - 50;
document.getElementById("moto").style.left = xn+"px"
}
function car_right () {
x = 0;
x = document.getElementById("moto").offsetLeft;
xn = x + 50;
document.getElementById("moto").style.left = xn+"px"
}
</script>
----HTML----
<img src="http://rockmotiv.ru/sources/reticle-2-large.png" id="moto" style="position:absolute; top:50%px; left:50%; width:100px">
<input type="button" value="Вниз" onclick="car_down()">
<input type="button" value="Вверх" onclick="car_up()">
<input type="button" value="Влево" onclick="car_left()">
<input type="button" value="Вправо" onclick="car_right()">
Не забудь подключить библиотеку jquery
Онлайн: 5
Время:
Gen. 0.0713
(c) Bym.Guru 2010-2026