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

200
Views
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 answers
Answer question

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 Report

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