当大胆的弹出窗口打开时隐藏div

时间:2015-11-19 16:20:47

标签: javascript jquery html css

嗨我使用了大胆的弹出式图像库,我希望在图像放大时隐藏div,并在图像缩小时再次显示。这是我的代码:

 $('.gallery-item').magnificPopup({
        type: 'image',
        gallery:{
          enabled:true
        },
        mainClass: 'mfp-with-zoom', // this class is for CSS animation below

        zoom: {
        enabled: true, // By default it's false, so don't forget to enable it

        duration: 300, // duration of the effect, in milliseconds
        easing: 'ease-in-out',


         // CSS transition easing function

        // The "opener" function should return the element from which popup will be zoomed in
        // and to which popup will be scaled down
        // By defailt it looks for an image tag:
        opener: function(openerElement) {
          // openerElement is the element on which popup was initialized, in this case its <a> tag
         // you don't need to add "opener" option if this code matches your needs, it's defailt one.
         return openerElement.is('img') ? openerElement : openerElement.find('img');
       }
      }

});

我应该在哪里放置hide()和show()函数,以便在弹出窗口的同时触发它们。

2 个答案:

答案 0 :(得分:0)

在您的打开功能中使用此$( ".main" ).hide();

答案 1 :(得分:0)

不要使用css,jQuery内置了显示和隐藏元素的功能。

open: function(){
  $(".main").hide();
},
  close: function(){
  $(".hidden-div").show();
}