html - Bootstrap 模态弹出窗口隐藏或关闭

标签 html css twitter-bootstrap bootstrap-modal

我的模态 Bootstrap 有问题。 我尝试创建一个模态,并在模态中创建一个模态弹出框。 结果是它是打开的,而不是仅在我单击按钮时打开。

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
<div class="modal-body">
    <a href="#" role="button" class="btn btn-default popover-test" title="" data-content="And here's some amazing content. It's very engaging. right?" data-original-title="A Title" aria-describedby="popover64665">button</a>
    <div class="popover fade right in" role="tooltip" id="popover64665" style="top: 0px; left: 112px; display: block;">
        <div class="arrow" style="top: 50%;"></div>
        <h3 class="popover-title">A Title</h3>
        <div class="popover-content">And here's some amazing content. It's very engaging. right?</div>
    </div> 
</div>
</div>

我的 jsfidle

最佳答案

1) 你需要包含 jQuery.jsbootstrap.js + bootstrap.css

2) 如果没有 JS 它就无法工作,所以你需要设置例如 script.js

3) 在 HTML 中设置 <script src="script.js"></script>

4) 在script.js类型:

$('#myModal').on('shown.bs.modal', function () {
  $('#myInput').focus();
});

希望对您有所帮助... CODEPEN.io

关于html - Bootstrap 模态弹出窗口隐藏或关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34232483/

相关文章:

php - 将 Bootstrap 集成到 codeigniter

twitter-bootstrap - bootstrap 和 flex 中的聊天气泡?

javascript - 多个元素的相似类名,但在纯纯 JS 中独立执行事件

html - 为某些 NSXMLElements 保存 NSXMLDocument 转义 HTML

html - 带有内联 block 和垂直对齐的奇怪垂直间距

css - Align 属性在 HTML5 中仍然可用吗?

javascript - IE11 style.maxHeight 不是从 css 设置的

HTML、CSS 3 列布局显示 :inline-block gap

css - 图像固定在中心的框内

html - 使用 CSS3 为长方体添加倒 Angular