Delete only all elements starting with "id_"
2 answers
You can use an attribute with a selector:
$("[id^='id_']").remove();
Edit (see comments)
Your question says "all elements", so the selector in my example is not as specific as it could be. If you care about performance (in the real world, what makes this selector more specific will not make any noticeable difference), then you should make your selector as specific as possible. If you need only div
elements, apply only the "start-with" to div
elements:
$("div[id^='id_']").remove();
+11