My code goes like this.
-
Use
var count = $("#some_id").find('img').length;
讨论(0)
-
Or the plain version without jQuery:
document.getElementById("some_id").getElementsByTagName("img").length
讨论(0)
-
var count = $("#some_id img").length;
It will give you total length of images inside a div.
讨论(0)
-
Try this
var count = $('#some_id').find('img').length;
讨论(0)
-
Count img inside #some_div:
$("#some_id img").length
If you want only the direct children, not all descendants:
$("#some_id > img").length
讨论(0)
-
var count = $("#some_id img").length
Select the image tags like this.
讨论(0)