Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/09/2014, 13:28
fcosun
 
Fecha de Ingreso: octubre-2011
Mensajes: 153
Antigüedad: 12 años, 6 meses
Puntos: 7
Cambiar imagen con select

Hola,

Como puedo cambiar de imagen al seleccionar un select, aca tengo este codigo.

Código HTML:
Ver original
  1.     <head>
  2.     <title>jQuery - Clases</title>
  3.         <script src="js/jquery-1.7.2.js" type="text/javascript"></script>
  4.     </head>
  5.    
  6.     <script type="text/javascript">
  7.         $(document).ready(function(){          
  8.             $("#seleccion").change(function() {
  9.                 var num = $(this).val();
  10.                
  11.                 if(num == 1){
  12.                     valor = 'manzana.jpg';
  13.                 }
  14.                 if(num == 2){
  15.                     valor = 'gato.jpg';
  16.                 }
  17.                
  18.                 $('#caja1').val(valor);
  19.             });          
  20.         });
  21.     </script>
  22.    
  23.  
  24. <select id="seleccion">
  25.     <option value='1'>Manzana</option>
  26.     <option value='2'>Gato</option>  
  27.  
  28. <img id="caja1" src='images/'/>
  29.  
  30. </body>  
  31. </html>
__________________
Mi mail: [email protected]