Topic: Jquery .html and .append not working in a modal.

robshelby priority asked 3 years ago

For some reason, Jquery's .html() and .append() don't seem to be working.

Do I need to re-render the modal?

Because I'll .append() a DIV in the modal and then I alert() the modal's .html() and it looks correct there.

But when the Modal is shown, the changes aren't there.

How do I re-render the modal so it reflects the changes?


Marcin Luczak staff answered 3 years ago


To which part of the modal you are appending the div? I've created the snippet where I append custom content to the .modal-body element and everything seems to be working fine.

If this doesn't work for you, please post a snippet with your code so I can check it, or try to append elements dynamically on and delete them on event. Otherwise, your custom elements will stack inside the modal body.

$("#modalSelector").on('', function(){
   // append elements
$("#modalSelector").on('', function(){
  // delete elements

Regards, Marcin

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB jQuery
  • MDB Version: 4.8.11
  • Device: windows
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No