Can you copy an existing div to a modal dialog

拥有回忆 提交于 2019-12-04 18:03:46

Please Try this

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

Only Change in Mark Up is I removed the class hide

$('.focusButton').click(function(){
    var newRow = $(this).parent().parent().parent('.sample').clone();
    $('#SampleModal .modal-body').html(newRow);
    $('#SampleModal').modal();
});

Check This Fiddle: http://jsfiddle.net/hoja/qsbkqc9m/12/

You can achieve this by using the following code

Using JQuery:

var html = $(id).html();

Using Javascript:

var html = document.getElementById(id).innerHTML;

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!