Ver Mensaje Individual
  #6 (permalink)  
Antiguo 16/03/2011, 20:07
santdavalos
 
Fecha de Ingreso: febrero-2011
Mensajes: 3
Antigüedad: 13 años, 2 meses
Puntos: 0
Respuesta: Calcular ancho y alto de una imagen

Al final lo resolvi asi, me parece un poco tosco pero me funciona por el momento! gracias gente!
Código Javascript:
Ver original
  1. <script>
  2.             window.onload=function(){
  3.                 img = document.getElementsByClassName("width-hor")
  4.                 for(i=0;i<img.length;i++){
  5.                     widthHor=img[i].width;
  6.                     countHor = img.length;
  7.                     totalHor = widthHor * countHor;
  8.                 }
  9.                 img = document.getElementsByClassName("width-ver")
  10.                 for(i=0;i<img.length;i++){
  11.                     widthVer=img[i].width;
  12.                     countVer = img.length;
  13.                     totalVer = widthVer * countVer;
  14.                 }
  15.                 totalWidth = totalVer + totalHor;
  16.                 alert(totalWidth);
  17.                 $('.content-item').css({width: totalWidth + 'px'})
  18.               }
  19.         </script>