title: Placing an element above an existing element JavaScript
body: <p>I'm using the drag and drop functionality with JavaScript.</p>
  <p>I have cards inserted into a panel and I want them to, when dragged, insert into the new panel depending on the urgency of the item.</p>
  <p><code>retrieveInd()</code> gets the urgency of an item, using a class connected to it, with a number so it is easier to compare: 0 to 3.</p>
  <pre class="lang-js prettyprint-override"><code>function retrieveInd(u) {
      var us = ['low','medium','high','critical'];
      for(x = 0; x &lt; us.length; x++){
          if(us[x] === u){
              return x;
          } 
      }
  }
    
  function drop(ev, el) {
  
      ev.preventDefault();
      var data = ev.dataTransfer.getData(&quot;text&quot;);
  
      let u = ((document.getElementById(data).getElementsByClassName('urgency'))[0].classList[1]);
  
  
      var els = el.querySelectorAll('.panel-item');
      
      els.forEach((elx) =&gt; {
          var cel = retrieveInd(elx.getElementsByClassName('urgency')[0].classList[1]);
          console.log(retrieveInd(u), cel)
          if(u &gt; cel){
              el.insertBefore(elx, document.getElementById(data))
          }
      })
  
  }
  </code></pre>
  <p>An example of a panel-item</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;panel-item&quot; draggable=&quot;true&quot; ondragstart=&quot;drag(event)&quot; id=&quot;panel-item-1&quot;&gt;
                          
                          &lt;div class=&quot;panel-item-title&quot;&gt;
  
                              panel title
                              
                          &lt;/div&gt;
  
                          &lt;div class=&quot;panel-item-urgency&quot;&gt;
  
                              &lt;div class=&quot;urgency critical&quot;&gt;&lt;/div&gt;
  
                          &lt;/div&gt;
  
                      &lt;/div&gt;
  </code></pre>
  <p>My code does not work, infact it doesn't actually let the drop functionality work.</p>
  <p>How can I make this work?</p>