Lara Lara - 4 months ago 16
jQuery Question

How to reset Modal body

I am trying to

body of the bootstrap modal dynamically. 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>

and here is the Jquery code to append the contents on click event of a button.


is the markup that got generated dynamically. Now issue is that with every button click event
is being added with the previous content. I need to reset the Modal, each time button is click.Please help.


Just use .html()


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. Additionally, jQuery removes other constructs such as data and event handlers from child elements before replacing those elements with the new content.