jQuery .remove()

jQuery .remove() removes target element;

js:

$(function(){
    $('.target').click(function() { // click to remove element
        $('.elements span:first').remove();
    });
});‚Äč

html:

<button class="target">click me to remove element</button>
<div class="elements">
  <span>elment 1</span>
  <span>elment 2</span>
  <span>elment 3</span>
  <span>elment 4</span>
  <span>elment 5</span>
</div>

Leave a Reply

Your email address will not be published. Required fields are marked *