SO jQuery Fiddle
Test Fiddle mainly for SO Questions jQuery 1.4.3, UI 1.8.5
by Nick Craver
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/ui-lightness/jquery-ui.css">
<div class = "current_parent level-0">
<a> Parent Link </a>
<ul class= "children">
<li class = "level-1">
<a href="#test"> Link to child </a>
</li>
<li class = "level-1">
<a href="#test"> Link to child </a>
</li>
<li class = "level-1 current_page_item">
<a href="#test"> Link to child </a>
</li>
</ul>
</div>
JavaScript
//Get URLs, run a length check against them. Execute functions are necessary. Pass the functions the relevant URL
var nextURL= $(".current_page_item").next().find("a").attr("href"); //Get the HREF of the next page in list
var previousURL= $(".current_page_item").prev().find("a").attr("href"); //Get the HREF of the previous page in list
if(previousURL === undefined){
alert ("Hiding prev URL!");
$('.previous_link').hide();
}else if(previousURL.length >= 1){
alert ("Setting prev URL!");
setPrevPageLink(previousURL);
}
if(nextURL === undefined){
alert ("Hiding Next URL!");
$('.next_link > a').hide();
}
else if (nextURL.length >= 1){
alert ("Setting next URL!");
setNextPageLink(nextURL);
}
function setPrevPageLink(previousURL) {
var prevTitle = $(".current_page_item").prev().find("a").attr("title"); //Get the title of previous page in list. WP provides.
$(".previous_link > a").attr("href", previousURL); //Set the 'Previous Link' to the URL of the previous item in list.
$(".previous_link > a").text(prevTitle); // Set the Title Text of the Link to the title of the previous Item in the List
alert ("Previous URL is" + previousURL + "and it's title is " + prevTitle + "and it's length is " + previousURL.length); //Drop an alert for Debug
}
function setNextPageLink(nextURL){
var nextTitle = $(".current_page_item").next().find("a").attr("title");
$(".next_link > a").attr("href", nextURL);
$(".next_link > a").text(nextTitle);
alert ("Next URL is" + nextURL + "and the title is" + nextTitle + "and it's length is" + nextURL.length);
}