Ver Mensaje Individual
  #4 (permalink)  
Antiguo 25/07/2007, 21:44
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Re: pasar valores a funciones dentro de anónimas

A ver ahora... lo que hice es agregarle un atributo al objeto (index):
Código PHP:
<!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 
algo(){
    var 
coleccion document.getElementsByTagName('div');
        for (var 
0coleccion.lengthji++) {
            
coleccion[i].index=i;
            
coleccion[i].onmouseover = function(){alert(this.id+'--'+i+'--'+this.index)};
        }
}

</script>
</head>

<body onload="algo()">
<div id="a" style="border:thin solid #000;margin:3px;">aaa</div>
<div id="b" style="border:thin solid #000;margin:3px;">bbb</div>
<div id="c" style="border:thin solid #000;margin:3px;">ccc</div>
</body>
</html>