Bootstrap close modal not working

I was stuck on this for a while also. I have no idea why but when I used data-bs-dismiss
in stead of data-dismiss in the class for the close button it worked for me.

data-dismiss is on Bootstrap 4.x version while data-bs-dismiss is on Bootstrap 5.x version.

Please see below full code for close button.

<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>

Leave a Comment