📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials jQuery in Practice jQuery with Bootstrap

jQuery with Bootstrap

5 min read
Bootstrap 5 does not require jQuery but works alongside it. Listen to Bootstrap events like show.bs.modal with jQuery's on(). Access Bootstrap component instances with bootstrap.Modal.getOrCreateInstance($('#id')[0]).

jQuery + Bootstrap 5

// Bootstrap 5 uses vanilla JS, but still works with jQuery
const modal = new bootstrap.Modal(document.getElementById('myModal'));

$('#openBtn').on('click', () => modal.show());
$('#closeBtn').on('click', () => modal.hide());

// Listen to Bootstrap events
$('#myModal').on('shown.bs.modal', function() {
  $('#firstInput').trigger('focus');
});