我剛剛重新鏈接Bootstrap 4.1到我的Bootstrap 5,我的模態停止作業。我的意思是當我的模態打開時它變成灰色,我不能點擊按鈕或退出它。我應該改變什么來作業Bootstrap 5?
這是我的代碼:
模態:
<!-- Creates the bootstrap modal where the image will appear -->
<div class="modal fade" id="imagemodal" data-backdrop="false" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Zamknij</span></button>
<h4 class="modal-title" id="myModalLabel">Podgl?d</h4>
</div>
<div class="modal-body">
<!-- <img src="" id="imagepreview" style="width: 400px; height: 264px;" > -->
<img src="" id="imagepreview" style="width: 400px; height: 264px;" >
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
JS:
$("#pop").on("click", function() {
$('#imagepreview').attr('src', $('#imageresource').attr('src')); // here asign the image to the modal when the user click the enlarge link
$('#imagemodal').modal('show'); // imagemodal is the id attribute assigned to the bootstrap modal, then i use the show function
});
uj5u.com熱心網友回復:
將data-屬性更改為data-bs-,如 bootstrap 5 ( https://getbootstrap.com/docs/5.0/migration/ )中遷移更改串列中的 Javascript 部分所述。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/379010.html
