如何通过锚标记使用Registers的Bootstrap模态? [英] How to use Bootstrap modal using the anchor tag for Register?

查看:54
本文介绍了如何通过锚标记使用Registers的Bootstrap模态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在导航栏中有一个锚标签列表.单击注册"时,我想打开一个模式.这是代码:

I have a list of anchor tags for my navigation bar. I want to open a modal when "Register" is clicked. Here is the code:

 <li><a href="@Url.Action("Login", "Home")">Login</a></li>
 <li><a href="#"> data-toggle="modal" data-target="modalRegister"> Register</a></li>

<div id="modalRegister" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title" style="text-align-last: center">Register</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

我通常使用按钮来打开模式,但是由于,我不太确定如何使用< a></a> 标记来打开它< a href"></a> .如何获得结果?

I normally use a button to open a modal, but I'm not quite sure how I would open it using the <a></a> tag because of the <a href""></a>. How can I achieve the results?

推荐答案

您将必须修改以下行:

<li><a href="#" data-toggle="modal" data-target="modalRegister">Register</a></li>

modalRegister 是ID,因此需要前面的#用于html中的ID引用.

modalRegister is the ID and hence requires a preceding # for ID reference in html.

因此,修改后的html代码段如下:

So, the modified html code snippet would be as follows:

<li><a href="#" data-toggle="modal" data-target="#modalRegister">Register</a></li>

这篇关于如何通过锚标记使用Registers的Bootstrap模态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆