bootstrap modal 如何关闭


本文摘自PHP中文网,作者藏色散人,侵删。

bootstrap modal关闭的方法:首先连接好bootstrap的插件;然后给按钮绑定模态框事件;最后通过“ $('#myModal').modal('hide');”方法手动关闭模态框即可。

本教程操作环境:Windows7系统、bootsrap3.3.7版,Dell G3电脑,该方法适用于所有品牌电脑。

推荐:《bootstrap视频教程》《css视频教程》

bootstrap modal手动关闭的方法:

关于模态框的写法:

在bootstrap的官方文档就有模态框的写法。bootstrap真心好用也很方便!

下面粘出来我的代码

首先得连接好bootstrap的插件,在html页面上连接上这两个包

b125f584afbf0620014327894e6b818.png

之后就是代码部分:

给按钮绑定了模态框事件

1

2

3

<button class="btn btn-primary btn-lg btn_add" style="display: block;" data-toggle="modal" data-target="#myModal">

一个按钮

</button>

模态框:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<!-- 模态框(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" style="width: 300px;margin: 0 auto">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">

                    &times;

                </button>

                <h4 class="modal-title" id="myModalLabel">

                    <!-- 模态框(Modal)标题 -->        

                </h4>

            </div>

            <div class="modal-body">

                <!-- 在这里添加一些文本 自定义内容-->

                <form>

                 <!-- 在这里添加一些文本 自定义内容-->

                </form>

            </div>

            <div class="modal-footer">

                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

                <button type="button" class="btn btn-primary btn_check">提交</button>

            </div>

        </div><!-- /.modal-content -->

    </div><!-- /.modal -->

</div>

这样就完成啦!如图,代码里面我把我的信息给删了,有的加上了注释:

阅读剩余部分

相关阅读 >>

bootstrap框架有哪些缺点?

bootstrap用哪个版本

bootstrap cdn是什么

浅谈bootstrap blazor组件的使用方法

bootstrap如何设置表格单选按钮

bootstrap被淘汰了么

解决bootstrap只加载一次 remote 数据的问题

浅谈bootstrap中的自适应屏幕

关于bootstrap model隐藏问题

bootstrap 基础教程之表单部分实例代码

更多相关阅读请进入《bootstrap》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...