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

162
Vistas
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 Respuestas
Responde la pregunta

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