Hello,
I have a <ul> element in which I use JS to place a number of <li> elements. These <li> elements have an attribute called 'index' which I use to jump around to different html pages.
HTML page.
Code:
<div id="scrubber">
<ul id="scrubberList">
<!--This is where the tick marks go for the page scrubber on the console.-->
</ul>
</div>
Code:
function createScrubberTicks(){
for(i=0; i< pages_arr.length; i++){
$('#scrubberList').append('<li><span id="' + pages_arr[i].title + '" index="' + i + '" class="scrubberBtn">'</span></li>');
}
$('.scrubberBtn')
.click(function(){
$(this).removeClass("scrubberBtn").addClass("scrubberBtnSelected").parent().siblings().children().removeClass('scrubberBtnSelected').addClass('scrubberBtn');
current_pg_ind = this.getAttribute("index");
$("#dev_current_pages").text(parseInt(current_pg_ind) + 1);
requestPage(current_pg_ind);
})
}
And now I need to find the <li> element with the correct index so that I can remove/add the class similar to above. The alert below does not work by the way.
How can I reference the correct <li> element based on this index number? (There can be up to 80 of these <li> elements)
Code:
function setScrubberIndex()
{
alert($("#scrubberList").getAttribute("index"));
}