Cita:
Iniciado por jeybi
Lo que tratan de decirte es que
var menu = document.getElementById(this);
es incorrecto, getElementById espera una string y tu le estas mandando un objeto. Supongo que lo que quieres es que cambie el border de ese div, solo necesitarias usar
this.style.borderColor=='#669900' ? this.style.borderColor='#99CC00' : this.style.borderColor='#669900';
ya que this apunta al elemento que llamo al metedo, en tu caso cada uno de esos divs.
En realidad, no. Cuando se aplica de esa manera, this refiere a window, no al elemento que dispara el evento:
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" />
<title>test</title>
<script>
function ver(){
alert(this)
}
</script>
</head>
<body>
<div onclick="ver()">test</div>
</body>
</html>
Si se testea en Firefox, es más claro: [object Window]. En Explorer: [object]
Y si en ambos, dentro del alert colocamos this.nodeName, devuelve undefined (si apuntara al objeto devolvería div).