Javascript Can';在页面加载时自动打开后,不要关闭fancybox

Javascript Can';在页面加载时自动打开后,不要关闭fancybox,javascript,jquery,fancybox-3,Javascript,Jquery,Fancybox 3,我对fancybox有一个问题,它会在页面加载时自动打开。单击关闭按钮后,fancybox再次打开 你能帮帮我吗 <script> jQuery(function($){ $(".popup-wrapper").fancybox({ 'padding': '0', 'max-width': '50%', 'max-height': '50%', 'autoSize': false, 'transitionIn': 'fade', 'transitionO

我对fancybox有一个问题,它会在页面加载时自动打开。单击关闭按钮后,fancybox再次打开

你能帮帮我吗

<script>
 jQuery(function($){
  $(".popup-wrapper").fancybox({
  'padding': '0',
  'max-width': '50%',
  'max-height': '50%',
  'autoSize': false,
  'transitionIn': 'fade',
  'transitionOut': 'fade',
  });

 $(".popup-wrapper").trigger('click');
});
</script>
php与html

<?php $args = array('post_type' => 'popup', 'showposts' => 5,); 
$the_query = new WP_Query( $args ); ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
$meta = get_post_meta( $post->ID, 'popup_details', true ); ?>

<?php if (is_array($meta) && $meta['displayPopup'] === '1') { ?>
<div class="popup-wrapper col-12 col-xl-12">
    <?php the_post_thumbnail(); ?>
</div><!-- .popup-wrapper -->
<?php }; 
endwhile;

wp_reset_postdata(); ?>

更新
只有当我单击“关闭”按钮时,问题才会出现。当我按下ESC按钮或单击黑色背景时,框会毫无问题地关闭。

我通过在代码中添加
preventDefault
解决了这个问题,现在它可以工作了。希望这对将来有帮助

jQuery(function($){
 $(".popup-wrapper").fancybox({
  'padding': '0',
  'autoSize': true,
  'transitionIn': 'fade',
  'transitionOut': 'fade',
 });

 $(".popup-wrapper").trigger('click');

 $(document).find('.fancybox-close-small').on('click', function(e) {
   e.preventDefault();
      self.close(e);
 });
});

你能发布一些html/css吗?这只是一种预感,但听起来好像密码触发了两次。可能与.trigger()有关。如果你评论那行行行吗?好的,我已经更新了我的问题
jQuery(function($){
 $(".popup-wrapper").fancybox({
  'padding': '0',
  'autoSize': true,
  'transitionIn': 'fade',
  'transitionOut': 'fade',
 });

 $(".popup-wrapper").trigger('click');

 $(document).find('.fancybox-close-small').on('click', function(e) {
   e.preventDefault();
      self.close(e);
 });
});