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

204
Views
¿Alguien puede decirme por qué este script.js no funciona?

¿Alguien puede decirme por qué esto no funciona? la intención es cambiar el título cuando se hace clic en un color rgb aleatorio (la función onclick ni siquiera aparece en mi página de git: https://lucaspaulii.github.io/portfolio/ )

 const title = document.getElementById("title"); let randNum = () => { let num = Math.floor(Math.random() * 255); return num } let randColor = () => { return 'rgb('+ randNum() + ',' + randNum() + ',' + randNum() + ')' } let newColor = randColor(); title.addEventListener('click', function onClick() { title.style.color = newColor; })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

está llamando a randColor solo una vez, llámelo dentro del controlador:

 const title = document.getElementById("title"); let randNum = () => { let num = Math.floor(Math.random() * 255); return num } let randColor = () => { return 'rgb('+ randNum() + ',' + randNum() + ',' + randNum() + ')' } title.addEventListener('click', function onClick() { title.style.color = randColor(); })
 <div id="title">click here</div>

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!