Count number of img tags inside a div tag

前端 未结 10 2013
暗喜
暗喜 2021-02-04 05:29

My code goes like this.

10条回答
  •  庸人自扰
    2021-02-04 06:00

    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.

提交回复
热议问题