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

159
Views
Javascript: fetch text and cut off

for the following html structure i want to extract 1 - 10 of 12 and keep only the last two characters of it, i.e. 12. How can I do this? I don't understand how to access elements or text without identifier.

<div class="paging-wrapper" xpath="1">
   <div class="paging-label">
      <!----><!----> 1 - 10 of  12 <!----><span>Text</span>
   </div>

I first tried to output the text at all, but it only finds the text in the <span> and not the characters I actually want.

cy.xpath("//div[@class='paging-wrapper']//div[@class='paging-label']").then(($pageCounter) => {
    const pageCount = $pageCounter.text()
    cy.log(pageCount)
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can remove the span for the paging-label div and then just get the text for that div and slice the last 2 elements

$(".paging-label").find("span").remove()
$(".paging-label").text().trim().slice(-2) // Return 12

That should return 12 for the example that you mentioned

You can play around removing the span, save it in a variable, getting the value that you need, and then adding the span again to the paging-label div in case that you needed

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!