jquery colorbox关闭HTML"立即下载"点击

时间:2014-08-29 21:09:18

标签: javascript jquery html

jquery colorbox正在运行,但我想在用户点击“立即下载”HTML

时将其关闭
     <script type="text/javascript">

     $( document ).ready(function() {
        setTimeout(function(){$('#cboxLoadedContent').show()}, 5000);
        setTimeout(function(){$('#overlay_full').show()}, 5000);
    });

    function close_pop_up()
    {
        $('#cboxLoadedContent').hide('slow');
        $('#overlay_full').hide('slow');
    }



      (function() {
        var sa = document.createElement('script'); sa.type = 'text/javascript'; sa.async = true;
        sa.src = ('https:' == document.location.protocol ? 'https://cdn' : 'http://cdn') + '.ywxi.net/js/1.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(sa, s);
      })();
    </script>

HTML

<a class="download_btn large" href="http://example.com"     title="Download">Download Now <img class="bd_arrow" src="images/btn_arrow.png" /></a>
                        </div>

1 个答案:

答案 0 :(得分:1)

只需在链接中添加click侦听器即可调用已存在的close_pop_up函数。

$( document ).ready(function() {
    setTimeout(function(){$('#cboxLoadedContent').show()}, 5000);
    setTimeout(function(){$('#overlay_full').show()}, 5000);
    // New code here
    $('.download_btn').on('click', close_pop_up);
});