get the elements number inside parent div jquery

社会主义新天地 提交于 2019-12-02 04:37:47
$("#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 
Kunal Vashist

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);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!