Home > Software design >  Bootstrap 5 modal not closing
Bootstrap 5 modal not closing

Time:03-02

I must be doing something silly.

I am programmatically opening a modal using $("#exampleModal").show();

The modal opens correctly. But for some reason - i do not get the dark overlay behind the modal - and the 2 close buttons do not work.

I had the class 'fade' applied as in the sample, but it meant the modal would not open at all.

JSFIDDLE: https://jsfiddle.net/kneidels/x9zwfumt/

CodePudding user response:

Here you go...

Change $("#exampleModal").show(); to $("#exampleModal").modal("show");. It solves everything you mentioned.

See the forked JSFiddle here.

  • Related