Search code examples
javascriptjqueryhtmlmobile-application

How to remove one class element at a time?


If I have a series of elements with class="filler", how can I remove one at a time without removing all of them? And this is without giving them all ids; there are a LOT of them.

For example, say I have this:

<br class="filler"/>
<hr class="filler"/>
<br class="filler"/>
<hr class="filler"/>
<br class="filler"/>
<hr class="filler"/>
<br class="filler"/>
<hr class="filler"/>

This repeats for quite a ways. I would like to remove one br and one hr each time a function is called. How can I do that?


Solution

  • To remove the first br and hr using jquery:

    $("br.filler").first().remove();
    $("hr.filler").first().remove();