Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vdchristelle/6492525 to your computer and use it in GitHub Desktop.
Save vdchristelle/6492525 to your computer and use it in GitHub Desktop.
add numbering to the menu blocks and the references slider Used in: LIS Hydraulics
$(document).ready(function(){
//add numbering to the menu blocks and the references slider
//needed: ul with class 'counter'
//reset variables
var i = 0;
var total = 0;
$('.subpages-overzicht').find('ul.counter').children('li').each(function(){
//look for the clone of the first li
if( $(this).hasClass('last') && $(this).hasClass('clone') && $(this).not('.begin') ) {
// add extra class
$(this).addClass('begin');
}
//look for the clone of the last item + add extra class
if( $(this).hasClass('clone') && $(this).hasClass('first') && $(this).not('.end') ) {
// add extra class
$(this).addClass('end');
}
//check wheter we should ++ the counter of non-clone list items
if( !$(this).hasClass('clone') && !$(this).hasClass('begin') && !$(this).hasClass('end') ) {
i++;
$(this).prepend('<div class="number">'+i+'</div>');
}
//add numbers to cloned list items
if( $(this).hasClass('.begin') ) { $(this).prepend('<div class="number">1</div>'); }
if( $(this).hasClass('.end') ) {
//set total number
var total = i;
$(this).prepend('<div class="numbertotal">'+total+'</div>');
}
}); //end each function
}); //end document ready function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment