L
L
ligisayan2016-03-23 17:51:59
JavaScript
ligisayan, 2016-03-23 17:51:59

How to hide part of the gallery of pictures in the spoiler?

Greetings! There is a site on wordpress with the NextGEN Gallery plugin installed. I want to make it so that the first 2 photos from the gallery are displayed, and the rest are hidden, and by clicking on the button the list is opened?
writing in crypto

window.addEventListener("load", function() {
  var height = $('.slideshowlink').height() + $('#ngg-image-0').height() * 2;
  var button = $('<button></button>');
  var gallery = $('.ngg-galleryoverview')
  button.html('Показать все').attr('type', 'button').css({
    position: 'absolute',
    top: 0,
    right: 0
  });
  button.prependTo(gallery);
  gallery.height(height);
  button.on('click', function() {
    gallery.css('height', 'auto')
  });
});

but, through the console, you can see that $('#ngg-image-0').height() cannot determine, because gallery not loaded yet

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question