javascript move div with arrow keys

preview_player
Показать описание
Show you how you can move an element with the arrow keys
Рекомендации по теме
Комментарии
Автор

The problem with this code is that 'top' is reserved for JS so u might need to change this variable name and then all should work. U should also show that u need to set value of 'position' value in css, but anyway it helps me out. Thanks

KubaKarki
Автор

I was having a problem in moving a div across the document, only tested in chrome, and the solution was to set the div style of position to absolute.


#box{
width: 50px;
height: 50px;

outline-style: solid;
outline-color: orange;
line-height: 50px;
text-align: center;
color:red;
position: absolute;
}

elsonmendes
Автор

+sub +like I have all the variables but i couldn't figure out how to move him!! should not have been this hard!

techmedia
Автор

it works fine on internet explorer, but on google chrome the element only moves left and right.. do you know how to fix this?

xbenjackson
Автор

I tried, but not working on key. Please help, how to solve? I am using on mac.

artdemocrat