Loading...
javascript
Bym
as
nightlight
Эпоха возмездия (RPG game)
WorldByte - Наш хостинг - партнер
Обучение/Помощь новичкам
| Помогите, как сделать перемещение картинки влево,
Топ дня:
O
Z
Z
Y
M
a
s
t
e
r
z
p
a
n
k
25 июня 2017, в 18:49
Рейтинг: 3494
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
Стр.:
1
,
2
Форум
На главную