Answers for "show more implementation jquery"

1

show more implementation jquery

var $li = $('ul li');
var $shPets = $('.shPets');

$shPets.each(function() {
  var petType = $(this).data('pet');
  $('ul li[data-pet=' + petType + ']')
    .not('.shPets') //not shPets
    .not(':first') //everything except first
    .hide();
});

$('.shPets').click(function() {
  var petType = $(this).data('pet');
  if ($(this).text() == 'Show More..') {
    $(this).text('Hide');
    $('ul li[data-pet=' + petType + ']').show();
  } else {
    $(this).text('Show More..');
    $('ul li[data-pet=' + petType + ']')
      .not('.shPets') //not shPets
      .not(':first') //everything except first
      .hide();
  }
});
Posted by: Guest on February-19-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language