Roy thomas Roy thomas - 6 months ago 9
jQuery Question

how to destroy the every <li> elements using each()

<ul>
<li class="list">Coffee</li>
<li class="list">Tea</li>
<li class="list">Milk</li>
</ul>


hi i having a code like above.I need to destroy only the
  • tags individually using jquery each()

    destroy method can be a private funtion.

    how to do this?

  • Answer

    $('li').each(function(){
    $(this).remove()
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <ul>
      <li class="list">Coffee</li>
      <li class="list">Tea</li>
      <li class="list">Milk</li>
    </ul>

    Comments