Need somebody to run an eye over this please. Sometimes it works on jsfiddle, sometimes it doesn't! Any improvements welcome.
http://jsfiddle.net/hotdiggity/JBqB3/8/
<ul id="list">
<li><a title="title" href="#">Lorem ipsum dolor sit amet</a>
</li>
<li>
<a title="title" href="#">Consectetur adipiscing elit
</a>
</li>
<li >
<a title="title" href="#">Ipsum dolor sit amet</a>
</li>
<li>
<a title="title" href="#">Lorem ipsum dolor sit amet</a>
</li>
<li>
<a title="title" href="#">Ipsum dolor sit amet</a>
</li>
</ul>
Here's the jQuery bit:
var more = $('<li><a class="more" href="">Show more</a></li>');
var less = $('<li><a class="less" href="">Show less</a></li>');
$('ul#list').children('li:gt(2)').hide();
$('ul#list').append(more);
$('.more').click(function(){
$(this).parent().hide().siblings('li').show();
$('ul#list').append(less);
return false;
});
$('.less').click(function(){
$('ul#list').children('li:gt(2)').hide();
$('ul#list').append(more);
return false;
});