.append mismatch with length

1

I have a script to generate images, and the images are generated with .append .

$(".fotos").append("<img src='" + size +"'/>");

The problem is that append does not generate the image in the source code, they are generated from the script itself, so I can not count how many images it has.

I use this to count, and always returns 1, with 10 images appearing.

alert($('img').parent('.fotos').length);

And it's like I said, it only returns 1.

Is there another way to do this?

    
asked by anonymous 02.02.2014 / 19:25

1 answer

3

Uses $(".fotos > img").length to select all images whose parent has the photos class.

Your current code selects all images, then selects the parent with class photos, and counts the parents

    
02.02.2014 / 19:28