Complete the code to create a new Bootstrap modal instance.
const myModal = new bootstrap.Modal(document.getElementById('myModal'), [1]);
The Modal constructor accepts an options object. Passing an empty object {} creates a modal with default settings.
Complete the code to show the modal using the JavaScript API.
myModal.[1]();open() which is not a Bootstrap modal method.toggle() which toggles visibility but is less explicit.The show() method displays the modal on the screen.
Fix the error in the code to hide the modal correctly.
myModal.[1]();close() which is not a valid method.remove() which deletes the element but does not hide the modal.The correct method to hide a Bootstrap modal is hide(). Methods like close() or remove() do not exist for modals.
Fill both blanks to create a modal instance and show it immediately.
const modal = new bootstrap.Modal(document.getElementById('exampleModal'), [1]); modal.[2]();
First, create the modal instance with an empty options object {}. Then call show() to display it.
Fill all three blanks to create a modal instance with keyboard disabled, show it, and then hide it.
const modal = new bootstrap.Modal(document.getElementById('modalId'), [1]); modal.[2](); modal.[3]();
Pass { keyboard: false } to disable closing the modal with keyboard. Then call show() to open and hide() to close it.
