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

226
Views
¿Existe una forma más sencilla de configurar el texto del cuerpo modal por nombre de clase?

Estoy usando Bootstrap 5.1.3 con Pure Vanilla JavaScript y puedo configurar el contenido .modal-body usando lo siguiente:

 function showBSModal(modalid, inputid) { var myModal = new bootstrap.Modal(document.getElementById(modalid), {}); var theValue = document.getElementById(inputid).value; const parent = document.getElementById(modalid); parent.querySelector(".modal-body").innerHTML = "Successfully Delete Uesr with ID: " + theValue; myModal.show(); };

Aquí estoy pasando modalid y la identificación de mi cuadro de entrada ( inputid ) dinámicamente y obteniendo el resultado deseado.

ingrese la descripción de la imagen aquí

myModal.querySelector en lugar de parent.querySelector pero no funcionó porque el navegador no acepta myModal.querySelector .

Pregunta: ¿Hay algo mejor que decir para lograr lo anterior?

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

0

myModal es un objeto modal y no un elemento HTML. Carguemos el elemento HTML, almacenémoslo en una variable y usémoslo en su lugar.

 function showBSModal(modalid, inputid) { let context = document.getElementById(modalid); var myModal = new bootstrap.Modal(context, {}); var theValue = document.getElementById(inputid).value; context.querySelector(".modal-body").innerHTML = "Successfully Delete Uesr with ID: " + theValue; myModal.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!