Disable click outside of bootstrap modal area to close modal(禁用在引导模式区域之外单击以关闭模式)
问题描述
我正在制作一个引导网站,其中包含几个引导模式".我正在尝试自定义一些默认功能.
I am making a bootstrap website, with a couple of Bootstrap 'Modals'. I'm trying to customize some of the default features.
问题是这样的;您可以通过单击背景关闭模式.无论如何要禁用此功能?仅在特定模式上?
Problem is this; You can close the modal by clicking on the background. Is there anyway to disable this feature? On specifc modals only?
引导模式页面
推荐答案
在选项章节,在你链接的页面中,你可以看到backdrop
选项.使用值 'static'
传递此选项将阻止关闭模式.
正如@PedroVagner 在评论中指出的那样,您还可以传递 {keyboard: false}
以防止通过按 Esc 关闭模式.
On Options chapter, in the page you linked, you can see the backdrop
option. Passing this option with value 'static'
will prevent closing the modal.
As @PedroVagner pointed on comments, you also can pass {keyboard: false}
to prevent closing the modal by pressing Esc.
如果你通过js打开模态框使用:
If you opening the modal by js use:
$('#myModal').modal({backdrop: 'static', keyboard: false})
如果您使用数据属性,请使用:
If you are using data attributes, use:
<button data-target="#myModal" data-toggle="modal" data-backdrop="static" data-keyboard="false">
Launch demo modal
</button>`
这篇关于禁用在引导模式区域之外单击以关闭模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:禁用在引导模式区域之外单击以关闭模式


基础教程推荐
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01