Closing Bootstrap modal onclick

后端 未结 4 2100
感动是毒
感动是毒 2021-02-08 02:18

I am using a Bootstrap modal for users to choose product options before adding an item to their cart. I\'ve used them before in this scenario with no issues but this one isn\'t

相关标签:
4条回答
  • 2021-02-08 02:47

    Close the modal with universal $().hide() method:

    $('#product-options').hide();
    
    0 讨论(0)
  • 2021-02-08 02:50

    You can hide the modal and popup the window to review the carts in validateShipping() function itself.

    function validateShipping(){
    ...
    ...
    $('#product-options').modal('hide');
    //pop the window to select items
    }
    
    0 讨论(0)
  • 2021-02-08 02:54

    If the button tag is inside the div element who contains the modal, you can do something like:

    <button class="btn btn-default" data-dismiss="modal" aria-label="Close">Cancel</button>
    
    0 讨论(0)
  • 2021-02-08 03:04

    Close the modal box using javascript

    $('#product-options').modal('hide');
    

    Open the modal box using javascript

    $('#product-options').modal('show');
    

    Toggle the modal box using javascript

    $('#myModal').modal('toggle');
    

    Means close the modal if it's open and vice versa.

    0 讨论(0)
提交回复
热议问题