Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
How to compare a string with number

I have a span id with textContent which have their own time(hour/minutes)

<div class="here">
<span class="time" >8 min</span>
</div>
<div class="here">
<span class="time" >22 min</span>
</div>
<div class="here">
<span class="time" >38 min</span>
</div>
<div class="here">
<span class="time" >1 hour</span>
</div>
<div class="here">
<span class="time" >1 day</span>
</div>

How can we show the span text whose time is less then 60 min, i don't want to show the text of span which contains 1 hour or 1 day any way to do that and yes string with number is necessary for my project.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

const els = document.querySelectorAll(".time")
els.forEach(el => {
  if (/(hour)|(day)/.test(el.textContent)) el.style.display = "none"
})
<div class="here">
  <span class="time">8 min</span>
</div>
<div class="here">
  <span class="time">22 min</span>
</div>
<div class="here">
  <span class="time">38 min</span>
</div>
<div class="here">
  <span class="time">1 hour</span>
</div>
<div class="here">
  <span class="time">1 day</span>
</div>

about 4 years ago · Juan Pablo Isaza Relatório

0

for(var i=0;i<5;i++){
    if(document.querySelectorAll(".time")[i].textContent.includes("min")){
        console.log(document.querySelectorAll(".time")[i].textContent);
    }
} 
}

This works too

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda