Home > Article > Web Front-end > Why is My Bootstrap Modal Throwing a \"TypeError: $(...).modal is not a function\" Error?
In an application using Codeigniter and Bootstrap, a dynamically inserted bootstrap modal fails to open with a "TypeError: $(...).modal is not a function" error.
Upon clicking a button to trigger the modal, the modal is inserted into the HTML successfully. However, when attempting to display it using $('#form-content').modal();, the error occurs.
The error is caused by an incorrect assumption that jQuery is loaded and available within the context of the script that attempts to use the modal() function.
Ensure that jQuery is correctly loaded and not accidentally included multiple times. A common source of multiple jQuery inclusions is the use of third-party plugins or themes that may already include jQuery.
By verifying that jQuery is loaded and available within the script's context, the modal() function can be used successfully to display the modal.
The above is the detailed content of Why is My Bootstrap Modal Throwing a \"TypeError: $(...).modal is not a function\" Error?. For more information, please follow other related articles on the PHP Chinese website!