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

95
Views
Actualizar DOM de popup.html después de hacer clic en el botón

Estoy haciendo una extensión de Chrome. Quiero actualizar un elemento h3 en popup.html con algo de texto después de hacer clic en un botón de envío con id de submit .

 <!-- popup.html --> <div class="row"> <h3 id="status"></h3> </div>
 // popup.js function saveClass() { var status = document.getElementById('status') status.innerText = 'success'; } document.getElementById("submit").addEventListener("click", saveClass);

La función rellena el elemento con el texto y veo el texto, pero desaparece inmediatamente, en unos microsegundos. ¿Dónde me estoy equivocando?

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

0

Para mí está funcionando bien. Puede consultar el siguiente fragmento de código

 <html> <body> <!-- popup.html --> <div class="row"> <h3 id="status"></h3> </div> <button id="submit">Submit</button> <!-- popup.js --> <script> function saveClass() { var status = document.getElementById('status') status.innerText = 'success'; } document.getElementById("submit").addEventListener("click", saveClass); </script> </body> </html>
about 4 years ago · Juan Pablo Isaza Report

0

El formulario actualiza la página de forma predeterminada al enviarlo, por lo que el texto completo desaparece. Simplemente agregue un detector de eventos para deshabilitarlo, lo que mantiene intacto el DOM.

 var form = document.getElementById("myForm"); function handleForm(event) { event.preventDefault(); } form.addEventListener('submit', handleForm);
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!