在Jquery函数中包含html代码 [英] Include html code within a Jquery function

查看:108
本文介绍了在Jquery函数中包含html代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下JQUery函数:
$ b $ pre $ $('button.forward')。click(function(){

});

一旦按钮向前 - 下面是按钮的代码 -
被点击,一个模态应该显示为这样

 <! -  Modal  - > 
< div class =modal fadeid =myModaltabindex = - 1role =dialogaria-labelledby =myModalLabelaria-hidden =true>
< div class =modal-dialog>
< div class =modal-content>
< div class =modal-header>
< button type =buttonclass =closedata-dismiss =modalaria-label =Close>< span aria-hidden =true>& times;<<< ; /跨度>< /按钮>
< h4 class =modal-titleid =myModalLabel>模式标题< / h4>
< / div>
< div class =modal-body>
...
< / div>
< div class =modal-footer>
< button type =buttonclass =btn btn-defaultdata-dismiss =modal>关闭< / button>
< button type =buttonclass =btn btn-primary>保存更改< / button>
< / div>
< / div>
< / div>
< / div>


解决方案

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

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

请参阅 Bootstrap JavaScript参考资料了解更多详情。


I have the following JQUery function

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

    });

where once the button forward - below is the code for the button - is clicked, a modal should appear as such

<!-- 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>

解决方案

Add that HTML code at the end of your page (inside the body tag) and add the following to your jQuery:

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

See the Bootstrap JavaScript reference for more details.

这篇关于在Jquery函数中包含html代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆