I’m trying to add images dynamically in a div element. So I have a block like that
<div id="gallery" >
<img src="images/slide1.jpg" alt="Slide 1 />
<img src="images/slide2.jpg" alt="Slide 2 />
<img src="images/slide3.jpg" alt="Slide 3 />
<img src="images/slide4.jpg" alt="Slide 4 />
</div>
The idea is to insert image dynamically after the first image so my new image goes after the first image. I tried appendTo, append , after, insertAfter .
Do you have any ideas ?
Thanks in advance 🙂
Perhaps this will help –
If you want to use the
insertAfter()function, you have to be sure that you have selected the correct element. In this case it isimgtag –:first>gallery. –$("#gallery")