1var $li = $('ul li');
2var $shPets = $('.shPets');
3
4$shPets.each(function() {
5 var petType = $(this).data('pet');
6 $('ul li[data-pet=' + petType + ']')
7 .not('.shPets') //not shPets
8 .not(':first') //everything except first
9 .hide();
10});
11
12$('.shPets').click(function() {
13 var petType = $(this).data('pet');
14 if ($(this).text() == 'Show More..') {
15 $(this).text('Hide');
16 $('ul li[data-pet=' + petType + ']').show();
17 } else {
18 $(this).text('Show More..');
19 $('ul li[data-pet=' + petType + ']')
20 .not('.shPets') //not shPets
21 .not(':first') //everything except first
22 .hide();
23 }
24});