Bonjour,
j'ai un petit soucis de compréhension,
Voici mon code Html:
et voici mon js (je veux faire un chargement image par image, ce n'est surement pas la meilleur solution, les suggestions sont les bienvenues):
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <div id="imageRow"> <a class="single first" href="img/lb/examples/image-3.jpg" rel="lightbox[plants]" title="Click on the right side of the image to move forward."><img src="" alt="Plants: image 1 0f 4 thumb" /></a> <a class="single" href="img/lb/examples/image-4.jpg" rel="lightbox[plants]" title="Alternately you can press the right arrow key." ><img src="" alt="Plants: image 2 0f 4 thumb" /></a> <a class="single" href="img/lb/examples/image-5.jpg" rel="lightbox[plants]" title="The script preloads the next image in the set as you're viewing."><img src="" alt="Plants: image 3 0f 4 thumb" /></a> <a class="single last" href="img/lb/examples/image-6.jpg" rel="lightbox[plants]" title="Click the X or anywhere outside the image to close"><img src="" alt="Plants: image 4 0f 4 thumb" /></a> </div>
Le soucis c'est que $('#imageRow').children().children()[i]; me retourne un [object HTMLImageElement] et non pas un "élément" jQuery car je voudrai utiliser une la fonction .load() par la suite mais je ne peux pas sur un [object HTMLImageElement] et j'aimerai bien comprendre pourquoi un tel retour.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 var url='img/'; var imgs= ['thumb-3.jpg', 'thumb-4.jpg', 'thumb-5.jpg', 'thumb-6.jpg']; var img; for( i=0; i!= imgs.length; i++){ img=$('#imageRow').children().children()[i]; img.src=url+imgs[i]; }
Merci d'avance!
Edit: Bon c'est finalement pas très étonnant, il ne reste plus qu'à trouver la solution qui doit ressembler à quelque chose du style:
R2.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 /*Draft*/ function loadImg(){ var url='img/'; var imgs= ['thumb-3.jpg', 'thumb-4.jpg', 'thumb-5.jpg', 'thumb-6.jpg']; var img; i=0; while(i!= imgs.length){ img=$('#imageRow').find('img'); img.attr('src', imgs[i]); img.load(function() { i++; }); }
Partager