2014-10-01 86 views
1

我使用查询雨创建弹出窗口,但我似乎无法弄清楚为什么当我点击第二个窗口的按钮出现时,即使它们具有不同的ID,也会显示后续窗口内容。Jquery Rqin中的多个弹出窗口

这里是我一起工作的代码:

<body> 

<!-- button to open the popup --> 
    <button class="my_popup_open">Open popup</button> 

    <!-- Add content to the popup --> 
<div id="my_popup"> 

    ...First pop-up... 

    <!-- Add an optional button to close the popup --> 
    <button class="my_popup_close"></button> 

</div> 


<!-- button to open the popup --> 
    <button class="my_popup_open">Open Second popup</button> 

    <!-- Add content to the popup --> 
<div id="my_popupTwo"> 

    ...Pop-up NUMBER TWO... 

    <!-- Add an optional button to close the popup --> 
    <button class="my_popup_close"></button> 

</div> 


    <!-- Include jQuery --> 
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 

    <!-- Include jQuery Popup Overlay --> 
    <script src="http://vast-engineering.github.io/jquery-popup-overlay/jquery.popupoverlay.js"></script> 

    <script> 
    $(document).ready(function() { 

     // Initialize the plugin 
     $('#my_popup').popup({ 
     opacity: 0.7, 
     transition: 'all 0.3s' 
     }); 

     // Initialize the plugin 
     $('#my_popupTwo').popup({ 
     opacity: 0.7, 
     transition: 'all 0.3s' 
     }); 

    }); 
    </script> 


</body> 

任何建议非常感谢!

回答

2

看来,这个插件不处理同一页上的多个弹出窗口。解决办法是做一点小事以显示选择的一个弹出窗口。

Link to the website of the plugin

试试这个:

<button onclick="$('#my_popup').popup('show');">Open popup</button> 

<button onclick="$('#my_popupTwo').popup('show');">Open Second popup</button> 

编辑:

关于关闭按钮:)

<button onclick="$('#my_popup').popup('hide');"></button> 

<button onclick="$('#my_popupTwo').popup('hide');"></button> 
+1

好主意!除了第二个弹出窗口上的关闭按钮外,其他功能都非常好。任何想法如何做一个小黑客的工作? – Tishok 2014-10-01 10:39:34

+0

我编辑了我的帖子:) – 2014-10-01 10:46:54

+1

哇,太简单了。如果你不能告诉,我在这个新的:)谢谢你的帮助! – Tishok 2014-10-01 10:51:26