How do I add a 2nd modal to my html page

后端 未结 2 420
[愿得一人]
[愿得一人] 2021-01-24 01:42

I didn\'t explain my problem in my last post.

So I want to add a second modal to my html page so if you click on \"Button 1\" it would open \"Modal 1\" and if you click

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-24 02:36

    You don't need to write javascript to hide or show modals use the right data-target and data-toggle in the button tag as shown below and bootstrap will automatically do the rest.

    Set data-toggle="modal" and data-target='' inside the button tag as shown above.

    To show two modal for two buttons just add the id of new modal in the data-target='' attribute in the new button.

    Now create multiple modals and give each of them a different

      

    UPDATED: ADDING CLOSE BUTTON TO CLOSE THE MODAL BY BOOTSTRAP

    Replace × in your modal with

    it will close the modal automatically on clicking close button on the modal.

    Here is an example of how to use two modals

    
    
    
      Bootstrap Example
      
      
      
      
      
    
    
    
    

    Large Modal

提交回复
热议问题