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

237
Views
¿Cómo hago un condicional con hasClass que imprima un texto dependiendo del contenido de otra etiqueta div?

Por ejemplo si tiene:

 <div>New York</div>

Así que me gustaría imprimir otro div como este:

 <div>Free Delivery</div>

¿Cómo haría eso usando JS?

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

agregar id al elemento:

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

y entonces

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

espero que haya sido útil

about 4 years ago · Santiago Gelvez Report

0

Puedes hacer esto con una condición js simple:

agregue una clase/id al elemento <div id="country">New York</div>

y en tu guion:

 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 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!