Using a bootstrap model here, each card in the model has a close button. Clicking on the close button will hide or remove the card from the model popup. If there is only one card left in the popup and I want to close that last card, I also want the model popup to automatically close. However, I am unable to achieve this on my own. Can someone please help?
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.modal-body{
height: 70vh;
overflow-y: auto;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container">
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
/* The rest of the HTML code remains unchanged */
</div>
<script>
$(document).ready(function(){
$('.clscurrent').on('click', function() {
$(this).closest('.removeit').remove();
});
});
</script>
</body>
</html>