Bootstrap 4 Modal 사용법
Modal -v4
일반적인 사용법
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
See the Pen flex : display by younghyeong ryu (@wangta69) on CodePen.
jquery를 이용한 수동 사용법
위의 예제에서 data-toggle="modal" data-target="#exampleModal" 을 제외한 모달 버튼을 사용하자.
<button type="button" class="btn btn-primary" id="toggle-btn">
Launch demo modal
</button>
$(function(){
$("#toggle-btn").click(function(){ // toggle
$('#exampleModal').modal('toggle')
})
$("#show-btn").click(function(){ // toggle
$('#exampleModal').modal('show')
})
$("#hide-btn").click(function(){ // toggle
$('#exampleModal').modal('hide')
})
})
See the Pen modal-bootstrap4-jquery by younghyeong ryu (@wangta69) on CodePen.