I have a problem with the jQuery dialog popup. Here's the code:
我有一个jQuery对话框弹出窗口的问题。这是代码:
<a href="#popup_open" class="btn sign-up popup wow fadeInLeft" data-wow-delay="0.4s">CLICK TO OPEN</a>
<div id="popup_open" style="display:none">
<div class="dialog">
POPUP CONTENT
<div class="popup_close">×</div>
</div>
</div>
and the js:
和js:
$('a.popup').popup();
I wrote a simple closing script, but it only works one time.
我写了一个简单的结束脚本,但它只能运行一次。
$(document).ready(function () {
$('.popup_close').click(function () {
$('.popup_back').css('opacity', '0');
$('.popup_cont').css('opacity', '0');
});
});
How do I make the popup close every time?
如何让弹出窗口每次关闭?
1 个解决方案
#1
0
One solution (though maybe not the best) is to add that click event on the close button in the function that opens the popup. If you go into developer tools and manually add the click event to the close button after the modal is open, it works every time.
一个解决方案(尽管可能不是最好的)是在打开弹出窗口的函数中的关闭按钮上添加click事件。如果您进入开发人员工具并在模式打开后手动将click事件添加到关闭按钮,则每次都可以使用。
Something like this could work:
像这样的东西可以工作:
$(".popup").click(function() { // Put the correct selector here, this is just a guess
// Opens the popup
$('a.popup').popup();
// Binds the click function
$('.popup_close').click(function () {
$('.popup_back').css('opacity', '0');
$('.popup_cont').css('opacity', '0');
});
});
There may be a cleaner solution but this is quick and dirty.
可能有一个更清洁的解决方案,但这是快速和肮脏的。
#1
0
One solution (though maybe not the best) is to add that click event on the close button in the function that opens the popup. If you go into developer tools and manually add the click event to the close button after the modal is open, it works every time.
一个解决方案(尽管可能不是最好的)是在打开弹出窗口的函数中的关闭按钮上添加click事件。如果您进入开发人员工具并在模式打开后手动将click事件添加到关闭按钮,则每次都可以使用。
Something like this could work:
像这样的东西可以工作:
$(".popup").click(function() { // Put the correct selector here, this is just a guess
// Opens the popup
$('a.popup').popup();
// Binds the click function
$('.popup_close').click(function () {
$('.popup_back').css('opacity', '0');
$('.popup_cont').css('opacity', '0');
});
});
There may be a cleaner solution but this is quick and dirty.
可能有一个更清洁的解决方案,但这是快速和肮脏的。