javascript - 当宏伟的弹出窗口打开时隐藏一个 div

标签 javascript jquery html css

您好,我为图片库使用 magnific pop-up,我想在图片放大时隐藏一个 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() 函数放在哪里,以便它们会与宏伟的弹出窗口同时触发。

最佳答案

不要为此使用 css,jQuery 内置了显示和隐藏元素的函数。

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

关于javascript - 当宏伟的弹出窗口打开时隐藏一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33809179/

相关文章:

jquery - 将按钮添加到表页脚

javascript - 带有来自 url(json 数据)的商店的 dojo dgrid 重新加载/刷新按钮

javascript - 如何在react js中导出复合组件

javascript - 将 HTML 中的用户输入值传递给 jQuery.Ajax

javascript - 使用 jQuery 用图像填充 div 只能工作第二次

html - li span 向左浮动 向右浮动

html - 如何并排对齐 4 张照片,以及它们下面的单独文字?

html - Openlayer弹出位置是底部中心

javascript - 具有不同对象的数组的indexOf

javascript - 在 Camel 案例转换中让 Camel 开心