JSFiddle - React, Tailwind, and code Playground

HTML

<ul id='myUL'>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
</ul>

<a href='#' id='first'>Get First LI</a>
<a href='#' id='last'>Get Last LIs</a>

JavaScript

jQuery(document).ready(function() {
    
        jQuery('#first').click(function(event) {
            alert( $('ul#myUL > li').first().text() );
        });
    
        jQuery('#last').click(function(event) {
            
            //alert( $('ul#myUL > li').text() );
            $('ul#myUL > li').each(function(index) {
                if( index !=  '0'){
                   alert(index + ': ' + $(this).text());
                }
             });
            
        });
});