我有以下HMTL:使用prependTo元素消失
<div class="modal fade in" id="data-confirmation-modal" tabindex="-1" role="dialog" aria-labelledby="data-confirmation-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<span class="fa fa-exclamation-triangle"></span>
<h4 class="modal-title" id="data-confirmation-modal-label">Titile</h4>
</div>
<div class="modal-body">
<p>Example</p>
</div>
<div class="modal-footer">
<button id="" type="button" class="btn-confirm">Conform</button>
<button type="button" class="btn-cancel" autofocus="" data-dismiss="modal">Avbryt</button>
</div>
</div>
</div>
</div>
我想创建一个表单元素,并把表单元素内模态含量javascipt的:
$form = $("<form></form>");
$form.prependTo($('.modal-content'));
当我使用上面的代码我模态是空的。希望得到一些帮助。 我想的HTML如下:
<div class="modal fade in" id="data-confirmation-modal" tabindex="-1" role="dialog" aria-labelledby="data-confirmation-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form>
<div class="modal-header">
<span class="fa fa-exclamation-triangle"></span>
<h4 class="modal-title" id="data-confirmation-modal-label">Titile</h4>
</div>
<div class="modal-body">
<p>Example</p>
</div>
<div class="modal-footer">
<button id="" type="button" class="btn-confirm">Conform</button>
<button type="button" class="btn-cancel" autofocus="" data-dismiss="modal">Avbryt</button>
</div>
</form>
</div>
</div>
</div>
如果我没有弄错,['prependTo()'](http://api.jquery.com/prependto/)不用于包装。它用于在目标元素的开始处添加/传输另一个元素 – Swellar