繁体   English   中英

苦苦挣扎jQuery延迟弹出窗体

[英]Struggling with jQuery delay popup form

我希望对我遇到的问题提供一些帮助。

我在我的网站newsletter-popup-conatiner上有一个弹出newsletter-popup-conatiner (是的,这是整个网站使用的容器的实际拼写错误)

根据我的理解,以下'应该'将弹出窗口延迟5秒。

setTimeout(function(){
  $('#newsletter-popup-conatiner).show();
},5000);

这是时事通讯模块。 经过几次不成功的尝试,我无法实际放置延迟代码。

$("#newsletter-popup-conatiner").mouseup(function(e){
        var popContainer = $("#newsletter-popup-conatiner");
        var newsLatterPop = $("#newsletter-pop-up"); 
        if(e.target.id != newsLatterPop.attr('id') && !newsLatterPop.has(e.target).length)
    {
      popContainer.fadeOut();
    }        
  });

  $('.hide-popup').on("click", function(){
    var popContainer = $("#newsletter-popup-conatiner");
    $('#newsletter-popup-conatiner')
    {
      popContainer.fadeOut();
    }
  });

  $('#dont_show').on("click", function(){
    $.cookie('popup_cookie', 'pclosed', {
      expires: 3,
      path: '/'
    });
    $('.hide-popup').trigger('click');
  });
  // console.log($.cookie('popup_cookie'));

  {% if settings.show_pupup and template == 'index'%}
  if($.cookie('popup_cookie') == 'pclosed') {
    $('.hide-popup').trigger('click');
  }
  {% endif %}

});

任何指导将不胜感激

<body onload="myFunction()">

<script>
function myFunction() {
  setTimeout(function() {
    $('#newsletter-popup-conatiner').show(); 
  }, 5000);
}
</script>
</body>

你可以试试这个。 它将在加载页面5秒后显示您的容器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM