Skip to content

Instantly share code, notes, and snippets.

@LBRapid
Created July 25, 2010 23:04
Show Gist options
  • Save LBRapid/489968 to your computer and use it in GitHub Desktop.
Save LBRapid/489968 to your computer and use it in GitHub Desktop.
$('ul.tag-list').each(function() {
if($(this).children('li').size() > 5) {
$(this).children('li:gt(4)').hide();
$(this).after('&nbsp<p class="show-hide-tags"><a href="#" data-open="0">&nbsp;[More]</a></p>');
}
});
$('.show-hide-tags a').click(function(e) {
e.preventDefault();
var $this = $(this);
if ($this.attr('data-open') == "0") {
$this.text("[Less]");
$this.attr('data-open', '1');
} else {
$this.text("[More]");
$this.attr('data-open', '0');
}
$('ul.tag-list').children('li:gt(4)').toggle();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment