Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

311
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda