You can use slideToggle()
.
$('.more').click(function(){
var max = 7;
$(this).closest("ul").find('li:gt(' + max + ')').slideToggle();
$(this).text($(this).text() == 'Show more' ? 'Close' : 'Show more');
});
You dont have to loop through each element to bind events. Simply use $('.more').
to bind events to all the elements with class namemore
Edit
$('.more').click(function(){
var max = 7;
$('.more').not(this).each(function(){
$(this).closest("ul").find('li:gt(' + max + ')').slideUp();
$(this).text('Show more');
});
$(this).closest("ul").find('li:gt(' + max + ')').slideToggle();
$(this).text($(this).text() == 'Show more' ? 'Close' : 'Show more');
});