I think i kind off miss some logical insight. It seems so easy, but i just don't see it..
I have a list and want to see if there are list items before and/or after the clicked item. Here's the code
<script>
[..]
$("a").click(function(event){
var parentEl = $(this).closest("ul");
var currPosition = $(this).parent().prevAll().length + 1;
var totalItems = $("#"+$(parentEl).attr("id")+" li").length;
if(currPosition == totalItems){ alert("Previous and Next"); }
if(currPosition <= totalItems){ alert("Next"); }
if(currPosition >= totalItems){ alert("Previous"); }
[..]
</script>
[..]
<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>
The code above almost works only one i click the last item, everything gets alerted.. I just want to know if there is a previous, next or both opions on the list-items that's clicked