Home » Jquery » jquery – How to achieve the same behaviour in javascript?-Exceptionshub

jquery – How to achieve the same behaviour in javascript?-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I’m working on a drag n drop simple project. Trying to get the javascript code to get the index of the dragged item. After searching found a similar code in jquery.

var index = $(e.target).index();

I want to get this done in javascript. Any help would be appreciated.

<div class="lists">
   <div class="list">
     <div class="list-item">Item 1</div>
     <div class="list-item">Item 2</div>
     <div class="list-item">Item 3</div>
     <div class="list-item">Item 4</div>
     <div class="list-item">Item 5</div>
   </div>
   <div class="list"></div>
   <div class="list"></div>
 </div>

This is the code im working on

How to&Answer: