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

126
Views
Accediendo a DOM con JS

Estoy tomando JS por mi cuenta. Este esfuerzo me expone a varias formas de lograr lo mismo en JS. En particular, me pregunto sobre la corrección de las siguientes formas de trabajar con el DOM.

Tengo una página html simple

 <body> <h1 class="red">I am red</h1> <h2 class="blue">I am blue</h2> <h3 class="yellow">I am yellow</h3> <script src="app.js"></script> </body>

Aquí, estoy tratando de cambiar el color de los elementos html con un evento de clic.

 document.body.addEventListener("click", function (event) { if (!(event.target === document.body)) { event.target.style.color = event.target.classList; } }); Array.from(document.body.children).forEach((child) => { child.addEventListener("click", function () { this.style.color = this.classList; }); });
about 4 years ago · Juan Pablo Isaza
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!