jQuery addClass example

Change class name on click in jQuery

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div>
  <ul>
    <li>Example 1</li>
    <li>Example 2</li>
    <li>Example 3</li>
  </ul>
</div>

<h4></h4>

CSS

li {
  list-style: none;
}

JavaScript

$('ul').sortable();

const orderedList = $('li');

orderedList.each(function(idx){
$(this).text(idx); 
})

const getValue = $('li:first-child').attr("value");
$('h4').text(getValue);