As pointed out by @bbird, your if-statements execute only one.
Perhaps you can use the onPagerEvent
callback to add and remove the <a>
tag to the active list item.
First add the following function:
function activateItem(index) {
$('#slideshow-nav').children('li').each(function (i) {
var $item = $(this);
if (i == index) {
if ($item.children('a').length == 0) {
$item.append('<a href="#">' + titles[i] + '</a>');
}
} else {
$item.children('a').remove();
}
});
}
Then call it once at the start:
activateItem(0);
And in the onPagerEvent
callback:
onPagerEvent: function (index) {
activateItem(index);
}
Edit: Updated the if-statement in the activateItem()
function so the <a>
element is appended to the list item's content, rather than replaces it.