Skip to content

Instantly share code, notes, and snippets.

@AlexanderLindsay
Created April 24, 2016 02:57
Show Gist options
  • Save AlexanderLindsay/f025550030d69bca903c780bb789ba78 to your computer and use it in GitHub Desktop.
Save AlexanderLindsay/f025550030d69bca903c780bb789ba78 to your computer and use it in GitHub Desktop.
javascript to clear a bootstrap modal on close
$(function () {
// when the modal is closed
$('#modal-container').on('hidden.bs.modal', function () {
// remove the bs.modal data attribute from it
$(this).removeData('bs.modal');
// and empty the modal-content element
$('#modal-container .modal-content').empty();
});
});
@Jawad121
Copy link

after $('#modal-container .modal-content').empty(); modal does not shows up.

@ssiva13
Copy link

ssiva13 commented Apr 21, 2019

kindly consider using the id or class of the element you want cleared or removed rather than the whole modal-content and modal-container classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment