Javascript how to add addEventListener after bootstrap modal shows

Viewed 20

How to add "addEventListener" after bootstrap modal shows with pure javascript not jQuery. The point of this is to get one of the modals div width when it loads. Version of bootstrap 4.6!!!!

1 Answers

You can use shown.bs.modal event listener for example you need to select the modal, let's say the modal id equal to myModal

const modal = document.getElementById('myModal');
modal.addEventListner('shown.bs.modal', () => {
  // enter your code here.
})

RESOURCE

Related