Hola a todos, tengo un sencillo ejemplo en javaScript y no me funciona en ninguno de los navegadores... y la verdad es que no entiendo por qué, ya que por lo menos en IE se que me ha funcionado otras veces ¿?¿?
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
.miestilo{
top:50px;
left:250px;
width:150px;
height:150px;
background:#FF0000;
}
</style>
<script language="javascript">
function movercapa(){
alert("mueve");
alert(document.getElementById('capa').id);
alert(document.getElementById('capa').style.top);
y = document.getElementById('capa').style.top;
y = parseInt(y);
y += 15;
document.getElementById('capa').style.top = y;
}
</script>
<title>Documento sin título</title>
</head>
<body>
<div id="capa" class="miestilo"></div>
<a href="#" onclick="movercapa()">xxx</a>
</body>
</html>
El alert(document.getElementById('capa').style.top); sale en blanco, el resto como se espera... Qué puede estar mal ¿?
Muchas gracias!!