I have the following HTML
<ul id="tabs">
<li>1</li>
<li>2</li>
<li>etc...</li>
</ul>
And the following jquery function I am using to append "buttons" for traversing "up" or "down" the list, while only "showing" the current item:
$('#tabs li').first().attr('class', 'current');
$('#tabs li').each(function(i) {
i = i + 1;
$(this).attr('id', 'tab-' + i);
if(i !== $('#tabs li').size()) {
$(this).append('<a class="tabPagination next floor-up" rel="tab-' + (i + 1) + '" href="/keyplate/' + (i + 1) + '">Up</a>');
}
if(i !== 1) {
$(this).append('<a class="tabPagination next floor-down" rel="tab-' + (i - 1) + '" href="/keyplate/' + (i - 1) + '">Down</a>');
}
});
$('#tabs li[class!="current"]').hide();
$(document).on("click", "a.tabPagination", function(){
$('.current').removeAttr('class');
$('#tabs li[class!="current"]').hide();
$('#' + $(this).attr('rel')).show();
});
I have another div:
<div id="tower"></div>
What I need to do is add a class to the #tower div, based on the currently selected #tab item. So for example if we are on #tab li = 2, then #tower div would get class="active_level_2". In other words, take the value of 'current' #tab list item and use that to create "active_level_#".
Thanks in advance!