gpt4 book ai didi

jquery - 两个弹出窗口无法正常工作

转载 作者:太空宇宙 更新时间:2023-11-03 20:16:56 24 4
gpt4 key购买 nike

我可以在我的站点中包含一个弹出窗口,但是当我想添加第二个时,它无法正常工作。

我正在寻找两个按钮,每个按钮都有单独的弹出窗口。

check Jsfiddlehere plugin offical site

这是怎么回事?

JQUERY

(function ($) {
$(function () {
$('#my-button,#my-button2').bind('click', function (e) {
e.preventDefault();
$('#element_to_pop_up,#element_to_pop_up2').bPopup();
});
});
})(jQuery);

CSS

#element_to_pop_up {
background-color:#fff;
border-radius:15px;
color:#000;
display:none;
padding:20px;
min-width:400px;
min-height: 180px;
}

.b-close {
cursor:pointer;
position:absolute;
right:10px;
top:5px;
};

#element_to_pop_up2 {
background-color: black;
border-radius:15px;
color:#000;
display:none;
padding:20px;
min-width:400px;
min-height: 180px;

HTML

<button id="my-button">POP IT UP</button>
<div id="element_to_pop_up"> <a class="b-close">x<a/>
Content of popup
</div>

<button id="my-button">POP IT UP</button>
<div id="element_to_pop_up2"> <a class="b-close">x<a/>
Content of popup
</div>

最佳答案

呃.. 看来这就是你想要的。

<button id="my-button" class="popBtn" data-toggle-pop="element_to_pop_up">POP IT UP</button>
<div id="element_to_pop_up"> <a class="b-close">x<a/>
Content of popup
</div>

<button id="my-button2" class="popBtn" data-toggle-pop="element_to_pop_up2">POP IT UP</button> <!-- You put my-button in your code -->
<div id="element_to_pop_up2"> <a class="b-close">x<a/>
Content of popup
</div>

JS:

jQuery(document).ready(function($) {
$('.popBtn').click(function() {
var target = $(this).attr('data-toggle-pop');
$('#' + target).bPopup();
});
});

fiddle :http://jsfiddle.net/HSCwC/

关于jquery - 两个弹出窗口无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18891461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com