Challenge - 5 Problems
Bootstrap Modal Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateWhat happens when you call show() on a Bootstrap modal instance?
Consider a Bootstrap modal instance created with JavaScript. What is the visible effect in the browser when you call the
show() method on this instance?Attempts:
2 left
💡 Hint
Think about what a modal does when it appears on the screen.
✗ Incorrect
Calling
show() on a Bootstrap modal instance makes the modal appear with a smooth fade-in effect and dims the background to focus user attention on the modal content.📝 Syntax
intermediateWhich code correctly initializes and shows a Bootstrap modal using JavaScript?
Given a modal element with id
myModal, which JavaScript snippet correctly creates a Bootstrap modal instance and shows it?Bootsrap
const modalElement = document.getElementById('myModal');Attempts:
2 left
💡 Hint
Bootstrap modal instances are created with
new bootstrap.Modal(element).✗ Incorrect
To use the Bootstrap modal JavaScript API, you create a new instance with
new bootstrap.Modal(element) and then call show() to display it.❓ rendering
advancedWhat is the visual result of calling hide() on a visible Bootstrap modal?
If a Bootstrap modal is currently visible on the page, what will the user see after calling the
hide() method on its JavaScript instance?Attempts:
2 left
💡 Hint
Think about how Bootstrap modals close when triggered by JavaScript.
✗ Incorrect
Calling
hide() triggers a fade-out animation for the modal and removes the backdrop dimming, returning the page to normal.❓ accessibility
advancedWhich attribute ensures a Bootstrap modal is accessible to screen readers?
To make a Bootstrap modal accessible, which ARIA attribute should be included on the modal's main container element?
Attempts:
2 left
💡 Hint
Accessibility roles help screen readers understand the purpose of UI elements.
✗ Incorrect
The
role="dialog" tells screen readers this is a dialog window, and aria-modal="true" indicates it blocks interaction with the rest of the page.❓ selector
expertWhich JavaScript code selects all Bootstrap modals currently shown on the page?
Bootstrap modals add the class
show when visible. Which code snippet correctly selects all visible modals in the DOM?Attempts:
2 left
💡 Hint
Use CSS selectors to find elements with multiple classes.
✗ Incorrect
The selector
.modal.show matches elements with both classes. querySelectorAll returns all such elements.