I have a div that contain many images:
<div id="#preview_images_gallery">
<img class="image_url pager" src="image1.jpg">
<img class="image_url pager" src="image2.jpg">
<img class="image_url pager" src="image3.jpg">
.
.
.
</div>
how I can know the number of images contained in this div with jquery?
$("#preview_images_gallery > img").size()
on second thoughts
$("#preview_images_gallery > img").length
$('#preview_images_gallery > img').length
var imagecount = $('#preview_images_gallery img').length
the length property of a jQuery collection.
Note : you should change your div id from #preview_images_gallery
to preview_images_gallery
alert($("#preview_images_gallery img").length);//return numbers of images inside preview_images_gallery
This is how you can count the img, in plain javascript
way :
var get=document.getElementById('preview_images_gallery');
var allget=get.getElementsByTagName('img');
alert(allget.length);