Search code examples
jquerylightboxmagnific-popup

Binding Magnific Popup plugin to a button (besides the gallery element itself)


I successfully implemented my Magnific Popup plugin, binding it to the gallery element (a div containing a set of img elements wrapped up in a elements). But I also want the lightbox to appear when clicking on a separate "see gallery" button.

I can't see anywhere how to achieve that in the documentation. Is it even possible?


Solution

  • You can just trigger click event via JS, e.g.:

    $('.popup-gallery').find('a').eq(0).trigger('click');