Ver Mensaje Individual
  #9 (permalink)  
Antiguo 13/01/2009, 17:29
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
Respuesta: problema con js this y settimeout

Probá así:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Pruebas</title>
<
link rel="stylesheet" href="css/lib.css" type="text/css" />
<
script type="text/javascript">
var 
tama 0;
function 
despliegasema(e) {
var 
tamer this.title;
var 
tamara this.value;
tama+=10;
if(!(
tama>=tamara)){

document.getElementById(tamer).style.height tama 'px';


}
var 
_this=this
window
.setTimeout(function(e){despliegasema.call(_this,e);},10);
}
window.onload = function(){
var 
listado document.getElementById('lista').getElementsByTagName('li');
for(var 
i=1i<listado.lengthi++) {
   (function(){
    var 
_i=i;
      
listado[i].onclick = function(e){despliegasema.call(listado[_i],e);}
     })()
    }
}
</script>

</head>
<body>
<div id="container">
<div id="lista">
<ul>
<li onclick="javascript:esconder();">esconder elementos de lista</li>
<li id="uno" title="desplegableuno" value="150" >despliega el primero</li>
<li title="desplegabledos" value="140" >despliega el segundo</li>
<li title="desplegabletres" value="160" >despliega el tercero</li>
<li title="desplegablecuatro" value="250" >despliega el cuarto</li>
<li title="desplegablecinco" value="100" >despliega el quinto</li>
<li title="desplegableseis" value="200" >despliega el sexto</li>
</ul>
</div>
<div id="listo">
<ul>
<li>no me borro</li>
<li>no me borro</li>
<li>no me borro</li>
</ul>
</div>
<div id="desplegableuno" >
<p>uno</p>
</div>
<div id="desplegabledos" >
<p>dos</p>
</div>
<div id="desplegabletres" >
<p>tres</p>
</div>
<div id="desplegablecuatro" >
<p>cuatro</p>
</div>
<div id="desplegablecinco" >
<p>cinco</p>
</div>
<div id="desplegableseis" >
<p>seis</p>
</div>
</div>
</body>
</html>