gpt4 book ai didi

javascript - 如何在同一页面的多个按钮上打开一个 Bootstrap 模态?

转载 作者:太空宇宙 更新时间:2023-11-04 16:21:02 25 4
gpt4 key购买 nike

我试图在同一页面的多个按钮上打开一个模式。不幸的是,我想不出这样做的方法。

我想在打开模态的同一页面上有多个注册选项,用户可以在模态上填写表格并注册..

使用当前代码,模式在第一个按钮上起作用,但在页面上的其他按钮上不起作用。 :(

谁能告诉我解决办法?

这是我的代码

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#signupModal">
Create an account
</button>


<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#signupModal">
Sign Up Here
</button>


<!-- Modal -->
<div class="modal fade" id="signupModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<div class="row">
<div class="col-sm-6 text-center col-xs-height">
<div class="signup-popup">
<h4>Signup Now</h4>

<input class="col-xs-12" type="text" name="username" placeholder="Email Address">
<input class="col-xs-12" type="password" name="password" placeholder="Password">
<input class="col-xs-12" type="password" name="confirmPassword" placeholder="Confirm Password">
<input class="btn btn-primary btn-filled col-xs-12" type="submit" value="Submit">
</div>
</div>

<div class="col-sm-6 col-xs-height">
<div class="signup-facebook">
<div class="signup-facebook-container">
<a class="btn btn-block btn-social btn-facebook signup-facebook-btn" href="#">
<i class="fa fa-facebook"></i> | Signup with Facebook
</a>
</div>

</div>

</div>
</div>
</div>

</div>
</div>
</div>

提前致谢!

最佳答案

确保添加了bootstrap jsbootstrap cssjquery。您的问题的解决方案。 jsfiddle 示例。请看一看 JSFIDDLE示例。

创建一个帐户

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#signupModal">
Sign Up Here
</button>


<!-- Modal -->
<div class="modal fade" id="signupModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<div class="row">
<div class="col-sm-6 text-center col-xs-height">
<div class="signup-popup">
<h4>Signup Now</h4>

<input class="col-xs-12" type="text" name="username" placeholder="Email Address">
<input class="col-xs-12" type="password" name="password" placeholder="Password">
<input class="col-xs-12" type="password" name="confirmPassword" placeholder="Confirm Password">
<input class="btn btn-primary btn-filled col-xs-12" type="submit" value="Submit">
</div>
</div>

<div class="col-sm-6 col-xs-height">
<div class="signup-facebook">
<div class="signup-facebook-container">
<a class="btn btn-block btn-social btn-facebook signup-facebook-btn" href="#">
<i class="fa fa-facebook"></i> | Signup with Facebook
</a>
</div>

</div>

</div>
</div>
</div>

</div>
</div>
</div>

关于javascript - 如何在同一页面的多个按钮上打开一个 Bootstrap 模态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29226462/

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