Hi All,
Bootstrap 5
I want to display multiple bootstrap modal one by one with showing previous modal in the background,
Ex: there are 3 models in that screen .while clicking button firtst modeal will display
after that in first modal having button to open 2nd modal , while opening the second modal first modal popup needed to display on the background of 2nd popup

Vishal JoshiPosted Jun 8, 2023, 8:22 AM
Hello Siva,
Try the below code for the expected result.
Thanks
Deepak RawatPosted Jun 8, 2023, 11:08 AM
Here's an example implementation:
HTML
JavaScript:
Explanation:
In the HTML code, there are two modal divs (
firstModalandsecondModal) with their respective content. Thedata-targetattribute in the button tag opens the first modal when clicked.In the JavaScript code, the
shown.bs.modalevent is triggered when the second modal is shown. We use this event to set thez-indexCSS property of the first modal to keep it in the background. The value 1050 is used to ensure it is below the second modal (Bootstrap's defaultz-indexfor modals is 1050).Similarly, the
hidden.bs.modalevent is triggered when the second modal is closed, and we reset thez-indexof the first modal to its original value.By setting the appropriate
z-indexvalues, the first modal will remain visible in the background when the second modal is opened. You can extend this pattern to add more modals by following a similar structure and adjusting the JavaScript code accordingly.Tuhin PaulPosted Jun 8, 2023, 8:25 AM
HTML:
Each modal should have a unique ID and a button to trigger the next modal:
Add buttons to trigger the modals and assign unique IDs to them
JavaScript/jQuery to handle the modal interactions.
The hidden.bs.modal event is triggered when a modal is closed, and shown.bs.modal event is triggered when a modal is fully shown. These events are used to control the display of the modals.
Vishal YelvePosted Jun 8, 2023, 7:36 AM
Hi Siva,
Do refer below link
https://www.cssscript.com/nested-bootstrap-5-modal/