How do I select an element that has the same class?

  • 0
    The & lt; div & gt; element has 4 & lt; li & gt; :
    <div>
             <li class="asd"></li>
             <li class="dsa"></li>
             <li class="asd"></li>
             <li class="dsa"></li>
      </div>

    You need to remove the first two items. If you just delete by class asd, the first and third are deleted. How do I remove the first two & lt; li & gt; from the top without changing the class?
    JavaScript Anonymous, Oct 28, 2019

  • 2 Answers
  • 0
    Anonymous

  • 0
    document.querySelector('.asd').remove();
    document.querySelector('.dsa').remove();
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!