gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
bootstrap5 onfirm
- User
bootstrap5 onfirm
- Assistant
bootstrap5 onfirm
It seems there might be a small typographical error in your query. If you meant "Bootstrap 5 confirm," I assume you're asking about creating a confirmation dialog using Bootstrap 5. Bootstrap 5 doesn’t include built-in dialog boxes specifically for confirmations, but you can easily create one using modals.
Here's a basic example of how you might set up a confirmation dialog using a Bootstrap 5 modal:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
<title>Bootstrap 5 Confirmation Modal</title>
</head>
<body>
<!-- Button to trigger the modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#confirmModal">
Delete Item
</button>
<!-- Modal -->
<div class="modal fade" id="confirmModal" tabindex="-1" aria-labelledby="confirmModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmModalLabel">Confirm Deletion</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to delete this item?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="confirmBtn">Delete</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/5.3.0/js/bootstrap.min.js"></script>
<script>
document.getElementById('confirmBtn').addEventListener('click', function() {
// Perform the action to delete the item
console.log('Item deleted');
// Close the modal
let modal = bootstrap.Modal.getInstance(document.getElementById('confirmModal'));
modal.hide();
});
</script>
</body>
</html>
data-bs-target="#confirmModal".You can customize the text, style, and behavior to fit your specific needs.