我如何才能显示一个成功的消息后,人按提交了一个表单在引导模式

How can I display a sucess message after person pressed submitted a form in bootstrap modal?

本文关键字:一个 提交 模式 表单 显示 消息 成功      更新时间:2023-09-26

我正在制作一个网站的原型,我正试图使它看起来像一个人提交一个表单接收他们的信息在一个引导模态的东西。

我在我的页面顶部有这个登录:

<div class="center-top-div">
        <form class="well inline-form" action="sidor/my_page.html" method="">
            <input type="text" class="span2" placeholder="Username">
            <input type="password" class="span2" placeholder="Password">
            <a href="sidor/index_inloggad.html" class="btn btn-small btn-primary pull-right" id="logga-in-btn">Log in</a><br>
            <a class="pull-right" id="amnesi" href="#myModal" data-toggle="modal">Forgotten?</a>
        </form>
    </div>

当点击链接"Forgotten?"时,会显示一个模式:

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
           <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
           <h4 id="myModalLabel">Vi behöver din E-postadress!</h4>
        </div>
        <div class="modal-body">
            <form class="well inline-form larger-input">
                 <input class="input-large" type="text" class="span2" placeholder="Din E-postadress...">
                 <a href="//I WANT THIS TO LINK TO ANOTHER MODAL/GREETING MESSAGE" class="btn btn-small btn-primary pull-right" 
                    id="logga-in-btn">Get my details!</a><br>
            </form>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
</div>

我想要的是,当一个人点击"获取我的详细信息!"我想在情态或其他情态中显示问候信息或其他东西。

任何想法都将受到赞赏!:)

比尔

您需要为任何点击事件的发生使用事件委托。看看这是否满足你的需要。这将在模态本身中显示消息。

http://jsfiddle.net/spaXZ/

    $('body').on('click','#logga-in-btn' ,function(){
    $(this).closest('.modal-body').find('#grtmessage').remove().end().append($('<span id="grtmessage">Thank you, we have now email you your details</span>'));
});

如果你想显示为模态,你可以这样做:- http://jsfiddle.net/HxrHd/