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

208
Views
¿Qué debo hacer para que imprima la salida?

 document.addEventListener('DOMContentLoaded', function() { var test = document.getElementById("myText").value; var mapObj = { A: 'Eh' }; test = test.replace(/A/g, function(matched) { return mapObj[matched]; }) var check = document.getElementById("check"); check.addEventListener('click', function() { document.getElementById('demo').innerText = test; }, false); }, false);
 BODY { width: 520px; min-height: 250px; }
 <html> <body> <textarea rows="10" cols="50" id="myText"></textarea> <button id="check">translate</button> <textarea rows="10" cols="50" id='demo' readonly><p id='demo'></p></textarea> </body> </html>

es parte de mi código, es un traductor
se supone que funciona cuando hago clic en el botón traducir y luego imprimo el resultado en el cuadro del área de texto, pero no es así, ¿qué debo hacer para que funcione? Agradecería mucho la respuesta en cualquier tipo

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

0

Su variable de prueba no se actualizó cuando presionó el botón. He cambiado un poco el código para darle una idea de por dónde empezar. Echar un vistazo:

 document.addEventListener('DOMContentLoaded', function() { var check = document.getElementById("check"); check.addEventListener('click', function() { var test = document.getElementById("myText").value; var mapObj = { A: 'Eh' }; test = test.replace(/A/g, function(matched) { return mapObj[matched]; }) document.getElementById('demo').innerText = test; }, false); }, false);
 BODY { width: 520px; min-height: 250px; }
 <html> <body> <textarea rows="10" cols="50" id="myText">Type "A" and press translate.</textarea> <button id="check">translate</button> <textarea rows="10" cols="50" id='demo' readonly></textarea> </body> </html>

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!