The ways to introduce Bootstrap JS include: through CDN (bootstrap.bundle.min.js is recommended); downloading related files from local; installing through npm and introducing related modules.
Bootstrap How to introduce JS
To introduce Bootstrap JS, there are the following methods:
Method 1: Use CDN
<code class="html"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script></code>
Method 2: Download from local
bootstrap.js
file to your project. Method 3: Through npm
<code class="shell">npm install bootstrap</code>
Then introduce in your code:
<code class="js">import * as bootstrap from 'bootstrap';</code>
Instructions:
bootstrap.bundle.min.js
, which contains all JavaScript components. Using JS components
After introducing Bootstrap JS, you can use its JavaScript components. For example:
$('#myModal').modal()
$ ('#myTabs').tab()
$('#myCarousel').carousel()
See the Bootstrap documentation for more information on specific components.
The above is the detailed content of How to introduce js into bootstrap. For more information, please follow other related articles on the PHP Chinese website!