Skip to content

Instantly share code, notes, and snippets.

@imagehat
Created June 17, 2009 22:15
Show Gist options
  • Save imagehat/131548 to your computer and use it in GitHub Desktop.
Save imagehat/131548 to your computer and use it in GitHub Desktop.
// Split into two columns accounting for nested list items
var midway = Math.round($('#sitemap li').length / 2);
var $node = $('#sitemap li:eq('+midway+')');
var $parent = $node.parent().parent();
var marker = ( $parent.is('li') ) ? $('#sitemap > li').index($parent) : $('#sitemap > li').index($node);
$('#sitemap > li').each(function(i) {
if (i > marker) $(this).addClass('colsplit');
});
$('#sitemap li.colsplit').insertAfter('#sitemap').wrapAll('<ul class="columns-2"></ul>').removeClass('colsplit');
$('#sitemap').addClass("columns-2");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment