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

310
Views
How to close modal programmatically in Bootstrap with React?

I am using React, Bootstrap and jQuery all together. Don't ask me why, i know it's horrible, just don't have time to get rid of jQuery. I use Bootstrap v5 and I got a modal in there, js:

<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 here
        </h5>
      </div>
    </div>
  </div>
</div>

Now, I got the following as well, js:

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

and this <a just opens a modal which is great. Modal has a x button , js:

<button
  type="button"
  className="btn-close"
  data-bs-dismiss="modal"
  aria-label="Close"
></button>

and clicking on it just closes the modal.

Problem I need to be able to close the modal programatically. As you can see, bootstrap does all this with I think(not sure) - data-bs-dismiss="modal" , but now I need such thing programatically. I tried to setAttribute but didn't work.

Prefer to use direct js real quick somewhere that fixes it instead of another jQuery code.

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

0

https://getbootstrap.com/docs/4.0/components/modal/#methods

Show $('#myModal').modal('show')

Hide $('#myModal').modal('hide')

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!