十二、用modal 实现浮层效果

html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="/static/js/jquery-2.1.0.js"></script>
    <script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <script type="text/javascript" src="/static/js/json2.js"></script>
</head>
<body>
    <div>
        <div class="mycontainer">
            <table width="100%">
                <tr>
                    <td>
                        <button id='addFEIssue' name='addFEIssue' class="btn btn-primary" data-toggle="modal" data-target="#myModal">展示浮层</button>
                    </td>
                </tr>
            </table>
        </div>
        <!-- 模态框(Modal) -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel">浮层标题</h4>
                    </div>
                    <div class="modal-body">
                        <p style="color:red" align="center" id="warnP"></p>
                        <table class="table table-striped">
                            <tr>
                                <td>
                                    <p>显示测试信息</p>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" id="closeAddFEIssue" data-dismiss="modal">关闭
                        </button>
                        <button type="button" class="btn btn-primary" id="saveandsend">
                            提交并发送邮件
                        </button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
</body>
</html>

javascript:

<script>
// 点击弹出页关闭按钮时,设置增加前端资源上线为不可用
$('#closeAddFEIssue').on('click', function(e) {
    console.log('点击关闭按钮');
});
// 弹出页关闭时,设置增加前端资源上线为不可用
$('#myModal').on('hide.bs.modal', function(e) {
    console.log('浮层要隐藏了。。。');
});

$('#saveandsend').on('click',function(e){
    console.log('点击发送按钮');
    $('#myModal').modal('hide');
});
</script>

效果如下:
输入图片说明

modal支持的事件有一下4个,可以结合这几个事件添加自己的代码,完成想要的结果
输入图片说明

参考文章:
http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值