JSFiddle - React, Tailwind, and code Playground
HTML
<ul id="listOne">
<li><a>Text 1</a></li>
<li><a>Text 2</a></li>
<li><a>Text 3</a></li>
<li><a>Text 4</a></li>
</ul>
JavaScript
$("a").click(function(){
var itemsBefore = ($(this).parent().prev().length>0)
var itemsAfter = ($(this).parent().next().length>0)
if(itemsBefore && itemsAfter) alert("Previous and next");
else if(itemsBefore) alert("Previous");
else alert("Next");
});