How to remove all elements in a div after a certain div

后端 未结 5 1298
既然无缘
既然无缘 2021-01-20 04:31

So I have a div that is drawing in dynamic elements at its bottom and I want to hide these elements, no matter what their IDs are using javaScript/jQuery. Basically my HTML

5条回答
  •  情书的邮戳
    2021-01-20 05:17

    You are saying you don't want to target their "id", but is there some specific part in the id that will remain the same ?

    like for instance "dynamic-id-" ?

    If this is the case you can target them by using a "like selector". The code below would target all divs whose ID is starting with "dynamic-id"

    $('div[id^=dynamic-id]').each(function () {
      //do something here
    });
    

提交回复
热议问题