試試這個
$('#id1').modal("hide");
它應該是在if語句當開關處於接通狀態的模式的選擇ID應該是要隱藏或者刪除模式是關閉狀態
if(switch_button == on_state){
$('#id1').modal("show");
$('#id2').modal("hide");
}else{
$('#id1').modal("hide");
$('#id2').modal("show");
}
如果你不明白你需要放置什麼條件。只是如果,如果有一類開放或任何
if($('#switch_button').hasClass('open')){}
如果你不想直接打開該模式時,開關被改變,你可以修改它裏面的if語句
if(switch_button == on_state){
$('button1 of the first modal').click(function(){
$('#id1').modal("show");
$('#id2').modal("hide");
});
}else{
$('button2 of the second modal').click(function(){
$('#id1').modal("hide");
$('#id2').modal("show");
});
}
和開關按鈕確保你的模態有一個modal-lg類型,用於大型模態-md用於中型和模態-sm用於小型,以查看你的模態是不同的大小。
<!-- Large Modal Format -->
<div class="modal fade" id="large" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- Modal Content Here -->
</div>
</div>
</div>
<!-- Medium Modal Format -->
<div class="modal fade" id="medium" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
<!-- Modal Content Here -->
</div>
</div>
</div>
<!-- Small Modal Format -->
<div class="modal fade" id="small" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal Content Here -->
</div>
</div>
</div>
<!-- End Modal -->
開關狀態改變後我無法立即打開模式,我有另一個打開模式的按鈕。問題是按鈕並不總是按照開關狀態顯示模式,它只是第一次工作。 – suresh726
這兩種模態的區別是什麼? –
他們是兩個完全不同的模式,比如「School Form Modal」和另一個是「College Form Modal」。 – suresh726