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
Agregar código a la función de hacer clic en el botón

Tengo este botón <button id='a'></button> que activé su clic con js document.getElementById('a').onclick=function(){alert('Hello world');} . Cómo agregar código a esta función dentro de la etiqueta como esta <button id='a' onclick='this.onclick; alert('hello 2');'></button>

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

0

Puede llamar a addEventListener para agregar más detectores de click además del controlador onclick asignado originalmente en el HTML. Hecho de esta manera, ambos controladores se ejecutarán cuando haga clic en el botón.

 document.getElementById('a').addEventListener('click', function() { alert('2'); });
 <button id="a" onclick="alert('1')">Test</button>

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!