如何动态更改bootstrap模态体 [英] How to dynamically change bootstrap modal body
本文介绍了如何动态更改bootstrap模态体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我将Bootstrap模态定义为:
So I have Bootstrap modal defined as:
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Error</h4>
</div>
<div class="modal-body">
<p> </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
我想用jscript编辑空体。我是Javascript的初学者,所以我会感谢最简单的答案。
And I want to edit the empty body with jscript. Im a beginner in Javascript so I'll appreciate the simplest answer.
推荐答案
试试这个:
$('.modalShow').click(function(event){
event.preventDefault();
var e = $(this);
var title = e.data('title');
var body = e.data('value');
$("#myModal").modal("show");
$('#modal-title').html(title);
$('#modal-body').html(body);
});
这篇关于如何动态更改bootstrap模态体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文