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

326
Views
Cambiar el color del texto después de hacer clic en la entrada

Creé un botón para cambiar el color de fondo usando solo css y el problema al que me enfrento es que el texto permanece del mismo color después de que cambió el color de fondo.

El ID de la etiqueta es "interruptor" para cambiar el fondo. El ID del texto es "par".

Esto es lo que he probado:

 document.getElementById("switch").onclick = function() { document.getElementById("par").style.color = 'red'; }

Primero puse un mensaje de alerta para probar que funcionaba, y cuando hice clic en el botón de entrada, apareció la alerta del cuadro de mensaje. Sin embargo, cuando reemplazo el cuadro de alerta con el código de arriba, mi texto permanece del mismo color.

¿Alguna recomendación?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

 document.getElementById("switch").addEventListener("click", ()=>{ document.getElementById("par").style.color = 'red'; });
 #switch{ height : 100px; width : 100px; background-color : orange; opacity;0.25; }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div id="switch"> <p id="par">foo bar </p> </div> </body> </html>

 document.getElementById("switch").addEventListener("click", ()=>{ document.getElementById("par").style.color = 'red'; });
about 4 years ago · Santiago Gelvez 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!