Last active
December 9, 2016 06:20
-
-
Save Rachind/fc65185ae243c7bd64a837722136e418 to your computer and use it in GitHub Desktop.
Jquery show more
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.extend({ | |
hideOther: function(num){ | |
var elem = $(this); | |
$(elem).wrapAll('<div class="other-all-outer"></div>').attr('data-num', 2).after('<div class="more-btn btn btn-transparent">Загрузить еще</div>').children('.item').slice(num).wrapAll('<div class="other-all"></div>').parent().hide(); | |
$(this).closest('.other-all-outer').find('.more-btn').on('click', function(e){ | |
e.preventDefault(); | |
var offset_num = parseInt($(elem).data('num')), | |
count = num * offset_num; | |
$(this).closest('.other-all-outer').find('.other-all').children('.item').unwrap(); | |
offset_num++; | |
$(elem).data('num', offset_num).children('.item').slice(count).wrapAll('<div class="other-all"></div>'); | |
if($('.other-all', elem).length == 0) $(this).hide(); | |
}) | |
} | |
}) | |
$('section.gallery .swiper-wrapper').hideOther(8); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment