JQuery用另一个模态形式替换Modal表单

时间:2014-06-12 11:39:37

标签: jquery html5 twitter-bootstrap

是否可以通过单击模态窗体中的href来替换另一个模态窗体?

由于

1 个答案:

答案 0 :(得分:1)

请试一试。

HTML

<a href="#" id="launchModel1">Launch modal 1</a>

<div id="modal1" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel1" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      Modal 1
     <a href="#" id="launchModel2">Launch modal 2</a>
    </div>
  </div>
</div>


<div id="modal2" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel2" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      Modal 2
    </div>
  </div>
</div>

的Javascript

$("#launchModel1").bind("click", function(){
$('#modal1').modal('show');
});

$("#launchModel2").bind("click", function(){
   $('#modal1').modal('hide');
   $('#modal2').modal('show');
});

工作样本 - http://www.bootply.com/YR7UREs1Ck