📌 Objective: Learn how to use Bootstrap’s built-in JavaScript plugins to add interactive functionality to your website.
🔹 1. Introduction to Bootstrap JavaScript Plugins
Bootstrap comes with powerful JavaScript plugins that enhance UI elements without requiring additional third-party libraries.
💡 Why Use Bootstrap JavaScript Plugins?
✔️ Lightweight & Fast – No extra dependencies required.
✔️ Pre-built UI interactions – Modals, dropdowns, carousels, tooltips, etc.
✔️ Works with data attributes – No need to write custom JavaScript.
🔹 2. How to Use Bootstrap’s JavaScript Plugins
Bootstrap plugins can be used in two ways:
1️⃣ Using Data Attributes (No JavaScript required)
2️⃣ Using JavaScript API (More control and flexibility)
🔹 3. Bootstrap Modal Plugin
The Modal plugin creates popup dialogs for forms, alerts, and messages.
1️⃣ Using a Modal with Data Attributes
✅ Example: Basic Modal
🔹 What happens?
- Clicking the button opens a popup modal.
2️⃣ Controlling Modal with JavaScript
✅ Example: Opening & Closing a Modal Using JavaScript
🔹 What happens?
- Clicking “Open Modal” triggers the modal via JavaScript.
🔹 4. Bootstrap Tooltip Plugin
The Tooltip plugin adds hover-based text popups.
1️⃣ Adding Tooltips with Data Attributes
✅ Example: Tooltip on a Button
🔹 What happens?
- Hovering over the button displays a tooltip.
🔹 5. Bootstrap Popover Plugin
The Popover plugin adds clickable tooltips with extra content.
1️⃣ Popover Using Data Attributes
✅ Example: Clickable Popover
🔹 What happens?
- Clicking the button displays a popover with extra information.
🔹 6. Bootstrap Toast Plugin
The Toast plugin is used for lightweight notifications.
1️⃣ Creating a Toast Notification
✅ Example: Basic Toast Notification
🔹 What happens?
- A notification appears in the bottom right corner.
🔹 7. Bootstrap Collapse Plugin
The Collapse plugin toggles the visibility of content.
1️⃣ Collapsible Content
✅ Example: Click to Show/Hide
🔹 What happens?
- Clicking the button shows or hides the content.
🔹 8. Bootstrap Carousel Plugin
The Carousel plugin creates image sliders.
1️⃣ Creating an Image Slider
✅ Example: Image Carousel
🔹 What happens?
- The carousel automatically cycles through images.
📝 Lesson Recap Quiz
🎯 Test your knowledge of Bootstrap JavaScript Plugins.
📌 Multiple-Choice Questions (MCQs)
1️⃣ Which attribute is used to open a Bootstrap modal?
a) data-bs-modal="open"
b) data-bs-target="modal"
c) data-bs-toggle="modal"
d) data-bs-popup="true"
✅ Correct Answer: c) data-bs-toggle="modal"
2️⃣ What plugin displays hover-based text popups?
a) Toast
b) Tooltip
c) Collapse
d) Dropdown
✅ Correct Answer: b) Tooltip
📌 True or False
3️⃣ Bootstrap modals require JavaScript to function.
✅ Answer: True
4️⃣ The Carousel plugin can be controlled with JavaScript.
✅ Answer: True
🎯 Practical Challenge
✅ Add a Bootstrap tooltip to a button.
✅ Create a popover that appears when clicked.
✅ Build a toast notification that appears on page load.
✅ Post your solution in the discussion forum for feedback!
🎓 Lesson Summary
✅ Bootstrap JavaScript plugins add modals, tooltips, popovers, carousels, and more.
✅ Data attributes (data-bs-toggle
) enable plugins without JavaScript.
✅ Bootstrap’s JavaScript API (new bootstrap.Modal()
) provides more control.
Leave a Reply