show with effiect jquery code example
Example 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(':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(':first')
.hide();
}
});
Example 2: jquery to hide a div
<div id="main">
<p> Hide/show this div </p>
</div>
('#main').hide();
$("#main").css("display", "none");