LightGallery is counting wrong number of images.. here is jsfiddle code... In this jsfiddle i am append dynamical element with a div that is in html file.. Please check manually ... Why lightgallery is count wrong images ?

for(var i =0;i<=imagesarray.length-1;i++){

Changed line 12?

why i should do that ?

If you have 5 items and then loop 0 to 5. That's one too many.

Your choice of -1 or change i<= to i< whichever you can wrap your head around. The right way would be to drop the = sign but the key item is for you to think of the array count is one number and arrays start at zero so think about that.

That's the same code as above. Sorry but you need to think about your for loop harder.

An array of 5 items is indexed from 0 to 4. You have it from 0 to 5 so that's not 5 but 6. Keep thinking, you'll get it soon.

So is this a new issue? Your topic is "i have 5 imges and lightgallery shows 6 images." If you have a new issue, state it in a new thread so we can tackle that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.