javascript - 在 Jquery 函数中包含 html 代码

标签 javascript jquery html twitter-bootstrap twitter-bootstrap-3

<分区>

我有以下 JQUery 函数

 $('button.forward').click(function() {

    });

一旦按钮向前 - 下面是按钮的代码 - 单击,模态应显示为

<!-- 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-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

最佳答案

在页面末尾添加该 HTML 代码(在 body 标记内)并将以下内容添加到您的 jQuery 中:

$('#myModal').modal('show')

参见 Bootstrap JavaScript reference了解更多详情。

关于javascript - 在 Jquery 函数中包含 html 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28254670/

相关文章:

html - Div 不会 float 正确

html - Bulma - 导航栏 Logo 图像不适应导航栏高度。如何更改 Logo 图像的大小?

javascript - 为什么 lengthPal 将 testPalindrone.length 存储为数字?

javascript - "Error: write after end"与 csv 写入流

jquery - 在窗口内显示时网格高度问题

jquery - 阻止 jquery 函数多次执行

javascript - 将csv数据转换成数组格式

javascript - 如何记录一组具有相同名称但不同 id 的单选按钮的值?

javascript - 如何在 React 中渲染 HOC

javascript - 试图通过输入字符串来使程序停止运行