Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
open bootstrap modal programatically

I have the following modal in boostrap

 <div
        className="modal fade"
        id="exampleModal"
        aria-labelledby="exampleModalLabel"
        aria-hidden="true"
      >
        <div className="modal-dialog modal-dialog-centered">
          <div className="modal-content">
            <div className="modal-header">
              <h5 className="modal-title" id="exampleModalLabel">
                Select a wallet
              </h5>
              <button
                type="button"
                className="btn-close"
                data-bs-dismiss="modal"
                aria-label="Close"
              ></button>
</div>
</div>

and I got a a element that when clicking, shows the modal.

<a
                    className="nav-link wallet-btn"
                    data-bs-toggle="modal"
                    data-bs-target="#exampleModal"
                  >
                    Show Modal
                  </a>

If I want to close the button programatically, i do the following:

const el = document.querySelector('.btn-close');
    if(el) {
      // @ts-ignore
      el.click();
    }

How can I open this modal programatically by following the same idea/way ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use the Bootstrap method .show().

const modal = document.querySelector(".modal")

if (modal) {
  modal.addEventListener("click", function() {
    modal.show()
  })
}

For more refer to docs: https://getbootstrap.com/docs/5.0/components/modal/#show

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!