[英]How to reset Modal body
I am trying to append
body of the bootstrap modal dynamically. 我正在尝试动态append
引导程序模体的主体。 Here is the body Markup of the Modal. 这是模态的身体标记。
<!-- try to indent the codes for readability -->
<div class="modal-body">
<div class="row text-left" style="margin-left: 2em;">
<div class="form-group"></div>
</div>
</div>
and here is the Jquery code to append the contents on click event of a button. 这是在按钮的click事件上附加内容的Jquery代码。
$('.form-group').append(EditHTML);
EditHTML
is the markup that got generated dynamically. EditHTML
是动态生成的标记。 Now issue is that with every button click event EditHTML
is being added with the previous content. 现在的问题是,每个按钮单击事件都将EditHTML
与以前的内容一起添加。 I need to reset the Modal, each time button is click.Please help. 我需要重设模式,每次单击按钮。请帮助。
$('.form-group').html(EditHTML);
Description : When
.html()
is used to set an element's content, any content that was in that element is completely replaced by the new content. 说明:当使用.html()
设置元素的内容时,该元素中的所有内容都将被新内容完全替换。 Additionally, jQuery removes other constructs such as data and event handlers from child elements before replacing those elements with the new content. 此外,在用新内容替换那些元素之前,jQuery从子元素中删除了其他构造,例如数据和事件处理程序。
我不确定我是否理解正确:
$('.form-group').html(EditHTML);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.