两个模式弹出窗口均在单击任一按钮时出现 [英] Both modal popups appear on click of either button
问题描述
我正在twitter-bootstrap3中工作.单击按钮"mybtn"时,应弹出id ="myModal"的模态;单击按钮"mybtn2"时,应弹出id ="myModal2"的模态.但是当我单击两个按钮中的任何一个时,它们的bot都会弹出.该怎么办?
Im working in twitter-bootstrap3.On click of button "mybtn", the modal with id="myModal" should pop and on click of button "mybtn2", the modal with id="myModal2" should pop. But when I click on any of the two buttons , bot of them popup.What should I do?
登录/注册
Sign In/Up
<button id="mybtn2" style="display:none;"
class="btn btn-primary btn-lg" href="#signup" data-toggle="modal" data-target=".bs-modal-sm">
Sign In/Up
</button>
<div class="modal fade bs-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm" >
//code
</div></div>
<div class="modal fade bs-modal-sm" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm" >
//code
</div></div>
推荐答案
添加要定位的模式的ID.现在,您的data-target
属性指向同时应用于模态的bs-modal-sm
类.尝试尝试data-target="#myModal"
或data-target="#myModal2"
.
Add the ID of the modal you want to target. Right now, your data-target
attributes are pointing to the class of bs-modal-sm
which applies to BOTH of your modals. Try data-target="#myModal"
or data-target="#myModal2"
as appropriate.
这是一个bootply演示:链接
Here's a bootply demo: link
这篇关于两个模式弹出窗口均在单击任一按钮时出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!