JSFiddle - React, Tailwind, and code Playground

HTML

<ul id="links">
    <li><a href="index.php?#1">1</a></li>
    <li><a href="index.php?#2">2</a></li>
    <li><a href="index.php?#3">3</a></li>
</ul>

JavaScript

$('#links li a').click(function(e) {
    e.preventDefault()
    var current_link = this.hash.slice(1);
    var next_link = '';
    if ($(this).parent().next().length > 0)
       next_link = $(this).parent().next().find('a')[0].hash.slice(1);
    
    alert('this: ' + current_link + ' next: ' + next_link);
    //return false;

});