我有一个带有多个面板的仪表板来显示不同的信息,我希望能够添加一个按钮以模式显示面板。
我正在使用bootstrap,我能找到的只是已经编写的模态。我想复制div标签的内容,这是一个面板然后在模型中显示,但我不确定如何去做。面板的html如下所示。面板确实包含一个表,但我已经删除了代码。我环顾四周,但似乎找不到我需要的解决方案。我知道我需要使用jQuery,复制面板并将其添加到模态对话框的内容中。我试过这样做但没有运气。我已经包含了一个小提琴,以显示我采取的方法Here这确实启动了模态,但内容未显示,也没有关闭它的按钮。
非常感谢任何帮助。
面板的HTML代码:
<div class="panel sample panel-yellow message">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-flask fa-fw"></i>Sample Updates
<i class="fa fa-spinner fa-spin sample "></i>
<a id="refreshMessage" class="refreshButton pull-right" href="#"><span class="fa fa-refresh"></span></a>
<a id="hideMessage" class="refreshButton pull-right" href="#"><span class="fa fa-arrow-up"></span></a>
<a id="focusMessage" class="focusButton pull-right" href="#"><span class="fa fa-eye"></span></a>
</h3>
</div>
<div class="panel-body">
<center>
<h5 class="text-warning">Table shows samples created or modified in the last ten minutes</h5>
</center>
</div>
</div>
我要显示的面板的屏幕截图:
答案 0 :(得分:2)
请试试这个
<div class="panel sample panel-yellow message">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-flask fa-fw"></i>Sample Updates <i class="fa fa-spinner fa-spin sample ">
</i>
<a id="refreshMessage" class="refreshButton pull-right" href="#"><span class="fa fa-refresh"></span></a>
<a id="hideMessage" class="refreshButton pull-right" href="#"><span class="fa fa-arrow-up"></span></a>
<a id="focusMessage" class="focusButton pull-right" href="#"><span class="fa fa-eye"></span></a>
</h3>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-condensed table-hover table-bordered table-responsive">
<thead>
<tr>
<th>
New Samples
</th>
<th>
Modified Samples
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="sampleCount"></span>
</td>
<td>
<span class="sampleCount2"></span>
</td>
</tr>
</tbody>
</table>
</div>
<center>
<h5 class="text-warning">
Table shows samples created or modified in the last ten minutes</h5>
</center>
</div>
</div>
<div id="SampleModal" class="modal fade" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-body">
</div>
只有Mark Up中的更改才会删除类隐藏
$('.focusButton').click(function(){
var newRow = $(this).parent().parent().parent('.sample').clone();
$('#SampleModal .modal-body').html(newRow);
$('#SampleModal').modal();
});
答案 1 :(得分:1)
您可以使用以下代码
来实现此目的使用JQuery:
var html = $(id).html();
使用Javascript:
var html = document.getElementById(id).innerHTML;
希望这有帮助。