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

230
Vistas
How do I make a conditional with hasClass that prints a text depending on the content of another div tag?

For example if have:

<div>New York</div>

So I would like to print another div like this:

<div>Free Delivery</div>

How would I do that using JS?

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

add id to element :

<div id="country">New York</div>

and then

let country = $('#country')

setInterval(()=>{
   if(country.text()=='New York'){
      // Your code
      // exemple 
      alert('Congratulations ! We Ship for Free for New York 
            Customers');
   }
},3000)

i hope it was useful

about 4 years ago · Santiago Gelvez Denunciar

0

you can do this with simple js condtion:

add a class/id to to the element <div id="country">New York</div>

and in your script:

window.onload = () => {
  const country = document.querySelector('#country');
  const printdiv = '<div>Free Delivery</div>';

  if(country && country.textContent.trim() == 'New York'){
  document.querySelector('#country').insertAdjacentHTML('afterend',printdiv)
  }
}
about 4 years ago · Santiago Gelvez 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