Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
Some Javascript codes not working, only jquery codes

I have an external javascript file where I wrote jquery codes and javascript codes but the javascript codes aren't working only the alert is working.

I want some texts to flash different colors but it doesn't.

When I inspect elements using ctrl+shift+i I see the colors changing under inspect element, but it doesn't change in the webpage.

Something like it's running on the background or what I really don't know.

function flash() { var text = document.getElementById('sales'); text.style.color=(text.style.color=='red')? 'green' : 'red'; } var clr = setInterval(flash, 500)
<p id="sales"> <h3 style ="text-align: center; font-weight: bold;"> Flash Sales </h3></p>

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

If you properly check the inspection, you'll see that your HTML was changed from what you have. A <p> element cannot contain a <h3> element, and the DOM has been changed to <p id="sales"></p><h3>...</h3>.

As such, your CSS is being applied to the wrong place.

function flash() { var text = document.getElementById('sales'); text.style.color=(text.style.color=='red')? 'green' : 'red'; } var clr = setInterval(flash, 500)
<h3 id="sales" style ="text-align: center; font-weight: bold;"> Flash Sales </h3>

about 4 years ago · Juan Pablo Isaza Denunciar

0

I was able to solve the issue by removing the in-line styling all the way from the <h3 tag and styled it in css.

about 4 years ago · Juan Pablo Isaza Denunciar

0

In pure java script

document.querySelector('element name').style.color = 'red';

In jquery

$('element name').css({red : 'red'});  
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda