如何使用注册的锚标签使用引导模式? [英] How to use Bootstrap modal using the anchor tag for Register?

查看:17
本文介绍了如何使用注册的锚标签使用引导模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的导航栏有一个锚标记列表.单击注册"时,我想打开一个模式.代码如下:

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 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?

推荐答案

您将不得不修改以下行:

You will have to modify the below line:

<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>

这篇关于如何使用注册的锚标签使用引导模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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