<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<button id="modalBtn" class="button">click Here</button>
<div id="simpleModal" class="modal">
<div class="modal-content">
<span class="closeBtn">×</span>
<p>Hello..... Iam a modal</p>
</div>
</div>
<script src="main.js"></script>
//get the modal element
var modal = document.getElementById('simpleModal');
//get open modal button
var modalBtn = document.getElementById('modalBtn');
// get close button
var closeBtn = document.getElementsByClassName('closeBtn')[0];
// listen foe open click
modalBtn.addEventListener('click', openModal);
// listen foe close click
closeBtn.addEventListener('click', closeModal);
// listen foe close click
window.addEventListener('click', outsideClick);
//Function to open modal
function openModal(){
modal.style.display = 'block';
}
//Function to close modal
function closeModal(){
modal.style.display = 'none';
}
//Function to close modal
function outsideClick(e){
if (e.target == modal) {
modal.style.display = 'none';
}
}