JQuery - ayuda para principante

 
Vista:

ayuda para principante

Publicado por victor (1 intervención) el 03/08/2017 17:15:16
Aver el caso es que es un codigo facilito pero bueno, yo me lio tengo que conseguir cuando pique a las fotos me salga el precio, me ha dicho el profe que lo me es usar el this index un poco de ayudar por fa

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!doctype html>
<html>
 
   <head>
      <meta charset="utf-8"/>
      <title>Título de la página</title>
      <style type="text/css">
      .img{
         float: left;
         display: block;
         text-align: center;
      }
      img: active{
         outline: solid 2px red;
      }
      </style>
      <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
      <script type="text/javascript">
      $(document).ready(inici);
 
      imagen=["im1.jpg","im2.jpg","im3.jpg","im4.jpg","im5.jpg"];
      texto=["imatge1","imatge2","imatge3","imatge4","imatge5","imatge6"];
      preu=[100,200,300,400,500,600];
 
      function inici(){
           $("body").html("<section></section>")
         $("section").append("<button onclick='imagenes()'>ok</button>");
      }
 
      function imagenes () {
      $("button").click
         for(k=0;k<imagen.length;k++){
      $("body").append("<div class='img'><img id='"+k+"' onclick='mostrarPrecio("+k+"); $(this).style.outline=\"solid 2px red\"'; src='"+imagen[k]+"' width='200'></br>"+k+"</div>")
         }
 
      }
 
      function mostrarPrecio(img){
         var seleccionat = img;
 
         precio = preu[seleccionat];
 
         alert(precio);
      }
 
 
      </script>
   </head>
 
   <body>
   <div id="contenidor">
 
   </div>
 
   </body>
 
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 302
Oro
Ha mantenido su posición en JQuery (en relación al último mes)
Gráfica de JQuery

ayuda para principante

Publicado por xve (673 intervenciones) el 03/08/2017 19:39:10
Hola Victor, he probado tu código y funciona perfectamente!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar