How to get img inside a particular div using JQuery

前端 未结 4 1954
温柔的废话
温柔的废话 2021-02-05 09:27

I have to get all the image tags ids inside a particular div. How can I get that using JQuery?

4条回答
  •  别跟我提以往
    2021-02-05 09:45

    Rough guess, but try:

    var imgIds = new Array();
    
    $("div#divID img").each(function(){
        imgIds.push($(this).attr('id'));
    });
    

    You haven't given the name of the div, but I've used divId as the id of the div. Simply change that to suite your needs.

提交回复
热议问题