Online: 8619
We can show the modal and hide the modal using javascript
<style>
#myBtn {
width: 300px;
padding: 10px;
font-size: 20px;
position: absolute;
margin: 0 auto;
right: 0;
left: 0;
bottom: 50px;
z-index: 9999;
}
</style>
</head>
<body>
<div class="container">
<h2>Modal Methods</h2>
<button type="button" class="btn btn-info btn-md" id="myBtn">Hide Modal</button>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Modal Methods</h4>
</div>
<div class="modal-body">
Displays content in the body
</div>
<div class="modal-footer">
<button class="btn btn-success btn-lg">Modal footer</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$("#myModal").modal("show");
$("#myBtn").click(function () {
$("#myModal").modal("hide");
});
});
</script>
</body>
modal header, modal body, modal footer using button with class btn btn-info and id as myBtn and myModal$("#myModal").modal("show"); - It defaults shows the modal with dialog box and in the next linwe have $("#myBtn").click(function () { $("#myModal").modal("hide"); - which calls the button to click the function of the myModal to hide the modal #myBtn output