Solo cambia de posicion ( la carita) 2 veces. Además no se puede repetir 2 veces el mismo botón. Alguna solucion?
Os dejo el código para que veais los errores.
HTML:
Código:
CSS:<html> <head> <title>Troll Move</title> <link rel="stylesheet" type="text/css" href="troll.css"> <script language="javascript" src="troll.js" type="text/javascript"></script> </head> <body> <div class="tablero"></div> <div id="troll"></div> <div class="mando"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td> </td> <td><input type="button" value="o" onclick="arriba()"> </td> <td> </td> </tr> <tr> <td><input type="button" value="o" onclick="izquierda()"> </td> <td> </td> <td><input type="button" value="o" onclick="derecha()"> </td> </tr> <tr> <td> </td> <td><input type="button" value="o" onclick="abajo()"> </td> <td> </td> </tr> </table> </div> </body> </html>
Código:
JS:div.tablero{
background-color:black;
position:absolute;
top:0px;
left:0px;
visibility:visible;
z-index:1;
width:324px;
height:324px;
}
#troll{
background-image:url('trollface.JPG');
position:relative;
top:0px;
left:0px;
visibility:visible;
z-index:2;
width:54px;
height:54px;
}
div.mando{
position:relative;
visibility:visible;
z-index:3;
top:180px;
left:200px;
}
Código:
Espero que me podais ayudar. Gracias de antemano function arriba(){
var spencer=document.getElementById('troll')
spencer.style.top-='54px'
}
function izquierda(){
var spencer=document.getElementById('troll')
spencer.style.left-='54px'
}
function derecha(){
var spencer=document.getElementById('troll')
spencer.style.left+='54px'
}
function abajo(){
var spencer=document.getElementById('troll')
spencer.style.top+='54px'
}


