I would like to move to the left a div when pressing left keybord arrow.
function arrowright (event){
var vaiss= document.getElementById("vaisseau");
var size= vaiss.style.marginLeft;
alert(size); //here I get empty message
if (event.which==39)
vaiss.style.marginLeft=size+"5px";
alert (vaiss.style.marginLeft); // here I get 5px not previous left margin + 5px
}
Here CSS:
#vaisseau{
bottom:0;
position:absolute;
margin-left:300px;
display;block;
}
And HTML:
div id="vaisseau" class="elements"><img src="vaisseau.jpg"></div>
I think The problem is that it don't read the actual value of margin-left.
EDIT: the css style is in an external file