Open a Modal from another modal and close the first (launching) modal

后端 未结 6 2162
陌清茗
陌清茗 2020-12-24 09:42

I\'m using Bootstrap Modal Window plugin its work fine but i would like to open another model window when i click next and close first one. how can i do it?

         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 09:58

    @Deepak Yadav problem: data-dismiss="modal" removes modal-open class from body tag maybe there is one solution with JS:

    Add class to next-previous links

         Next
         previous
    

    JS:

    var $body = $('body')
      $("a.nextStep").click(function(){
       $body.addClass('modal1-on')
      });
      $("a.previousStep").click(function(){
       $body.addClass('modal2-on')
      });
    
      $('#modal-1').on('hidden.bs.modal', function () {
      $body.removeClass('modal2-on')
      });
      $('#modal-2').on('hidden.bs.modal', function () {
      $body.removeClass('modal1-on')
      });
    

    Then css:

        body.modal1-on, body.modal2-on {overflow: hidden;}
    

提交回复
热议问题