title: remove element javascript with classename
body: <ol>
  <li>when I remove this with id it works but when I tried with className it didn't work </li>
  </ol>
  
  <pre><code>    const remov= document.createElement('a');
      remov.classList='clsx';
      remov.textContent='X';
      remov.setAttribute("id", "Div1");
      remov.onclick = function (){
      document.getElementById('Div1').remove();    }
  </code></pre>
  
  <ol>
  <li>this is my code  im trying to remove the element that i've created with id 'Div1' emphasized text</li>
  </ol>
  
  <pre><code>const lista = document.getElementById('list');
  
  eventlisteners();
  
  function eventlisteners(){
    document.querySelector('#form').addEventListener('submit', yrlist);
  }
  
  //function
  
  function yrlist(e){
  
      e.preventDefault();  
      var textare =document.getElementById('textar').value;
  
  
      const li= document.createElement('li');
      li.textContent=textare;
      li.classList='clsli';
      li.setAttribute("id", "Div1");
  
      const remov= document.createElement('a');
      remov.classList='clsx';
      remov.textContent='X';
      remov.setAttribute("id", "Div1");
      remov.onclick = function (){
        document.getElementById('Div1').remove();
      }
  
      li.appendChild(remov);
  
      lista.appendChild(li);
  
  }
  
  </code></pre>