Ver Mensaje Individual
  #17 (permalink)  
Antiguo 22/11/2014, 17:45
javier_u
 
Fecha de Ingreso: noviembre-2014
Mensajes: 15
Antigüedad: 9 años, 5 meses
Puntos: 1
Respuesta: usar la misma funcion mas de 1 vez

Cita:
Iniciado por satanson123 Ver Mensaje
Usa el mismo ejemplo que te comente mas arriba:

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <!--
  3. Created using JS Bin
  4. http://jsbin.com
  5.  
  6. Copyright (c) 2014 by anonymous (http://jsbin.com/mukaxowufu/1/edit)
  7.  
  8. Released under the MIT license: http://jsbin.mit-license.org
  9. -->
  10. <meta name="robots" content="noindex">
  11.   <meta charset="utf-8">
  12.   <title>Ejemplo- FDW</title>
  13. <style id="jsbin-css">
  14. #bar{
  15.     display: block;
  16. }
  17.  
  18. .foo{
  19.     max-width: 400px;
  20. }
  21. </head>
  22.     <button id = "bar">Cambiar tamaño de imágenes</button>  
  23.  
  24.     <img src = "http://www.absolut-canada.com/wp-content/uploads/2009/09/pesca-en-quebec.jpg" class = "foo" />
  25.     <img src = "http://static3.absolutcaribe.com/wp-content/uploads/2009/09/playa-placencia.jpg" class = "foo" />
  26. <script id="jsbin-javascript">
  27. var boton = document.querySelector("#bar"),
  28.     imagenes = document.querySelectorAll(".foo"),
  29.     total = imagenes.length;
  30.  
  31. boton.addEventListener("click", function(){
  32.     for (var i = 0; i < total; i++){
  33.        if (getComputedStyle(imagenes[i]).maxWidth == "400px"){
  34.            imagenes[i].style.maxWidth = "120px";
  35.        }
  36.        else{
  37.            imagenes[i].style.maxWidth = "400px";
  38.        }
  39.    }
  40. }, false);
  41. </body>
  42. </html>

Solo tenias que borrar una imagen.

Este ejemplo sí funciona. Tengo que estudiarlo a ver si lo entiendo.
Funciona perfecto.

Muchísimas gracias.
Un saludo.