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

155
Views
¿La mejor manera de combinar múltiples funciones para mayor claridad?

Tengo un cuadro de entrada de texto que hace 3 cosas, comienza con el botón 'Informar un error' cuando está cerrado, al hacer clic, se abre un cuadro de texto y el botón Informar un error se convierte en 'Cerrar'. Ahora quiero combinar el código de todos los JS a continuación para trabajar con el siguiente botón HTML, pero no puedo ver una forma clara de avanzar en esto. Cuando lo probé, mi funcionalidad desapareció, o el botón simplemente ya no cambia el texto.

Botón HTML.

 <button id="myBtnToReportABug" onclick="toggleReportForm()" type="button" class="btn btn-secondary float-right">{{#if report_form_closed }} Report A Problem {{else}} Close {{/if}}</button> </div>

JS:

 // changes text on 'report problem' button when form open function change() { var theButton = document.getElementById("myBtnToReportABug"); if (theButton.innerHTML == "Close") theButton.innerHTML = "Report A Problem"; else theButton.innerHTML = "Close"; } // clears text field onclick function clearFields() { document.getElementById("nameInput").value = ""; } // changes text on 'submit' back to original button text when report is made function changeSecond() { var theButton = document.getElementById("myBtnToReportABug"); if (theButton.innerHTML == "Close") theButton.innerHTML = "Report A Problem"; } function toggleReportForm() { var report_form_closed = document.getElementById("myBtnToReportABug"); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

intente usar addEventListener;

 eg. function callback(){ //all the functions call them here } document.getElementById("myBtnToReportABug").addEventListener(callback)
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!