My code goes like this.
-
Try to get them like this:
var count = $("#some_id img").length;
讨论(0)
-
Use:
$("#some_id img").length
Here's a fiddle of it.
讨论(0)
-
Also (even though there are many right answers here), every of these methods in jQuery, such as children(), siblings(), parents(), closest(), etc. accept a jQuery selector as a parameter.
So doing
$("#some_id").children("img").length
should return what you need as well.
讨论(0)
-
use this
$("#some_id img").length
讨论(0)