Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/07/2009, 09:20
Avatar de eall
eall
 
Fecha de Ingreso: noviembre-2008
Ubicación: Concepcion
Mensajes: 127
Antigüedad: 15 años, 6 meses
Puntos: 8
Respuesta: jQuery: Problemas con uso de variable

el problema es que lo que tu quieres hacer está fuera del each.

Código javascript:
Ver original
  1. $(document).ready(function(){
  2.     imgs = document.getElementsByTagName("img");
  3.     $.each(imgs,function(i,n){
  4.         w = n.width; // w queda con el último valor.
  5.     });
  6.     $("img").css({width:80,height:80});
  7.     $("img").click(function(){
  8.         alert(w);
  9.     });
  10. });
  11.  
  12. $('img').click(function(){
  13.    var h = $(this).attr('width');
  14.    var w = $(this).attr('height');
  15.    $(this).animate({width:w,height:h},"slow");
  16. });

espero te ayude con tu problema...
__________________
tutoriales xajax, jQuery, PHP y otros en mi blog