本文摘自PHP中文网,作者藏色散人,侵删。
bootstrap modal关闭的方法:首先连接好bootstrap的插件;然后给按钮绑定模态框事件;最后通过“ $('#myModal').modal('hide');”方法手动关闭模态框即可。

本教程操作环境:Windows7系统、bootsrap3.3.7版,Dell G3电脑,该方法适用于所有品牌电脑。
推荐:《bootstrap视频教程》《css视频教程》
bootstrap modal手动关闭的方法:
关于模态框的写法:
在bootstrap的官方文档就有模态框的写法。bootstrap真心好用也很方便!
下面粘出来我的代码
首先得连接好bootstrap的插件,在html页面上连接上这两个包

之后就是代码部分:
给按钮绑定了模态框事件
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" >
×
</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>
|
这样就完成啦!如图,代码里面我把我的信息给删了,有的加上了注释:
阅读剩余部分
相关阅读 >>
web 开发里程碑时刻:bootstrap 宣布放弃支持 ie
bootstrap能和vue一起用吗
easyui和bootstrap之间有什么区别?
bootstrap如何消除浮动
bootstrap是响应式吗
bootstrap框架有哪些缺点?
bootstrap是css框架吗
浅谈查看bootstrap和jquery版本对应关系的方法
bootstrap怎么快速入门
bootstrap怎么添加样式表
更多相关阅读请进入《bootstrap》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » bootstrap modal 如何关闭