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

130
Visualizações
Make the amount of first and last characters displayed to be responsive to the width available

Maybe someone know how to make text or numbers inside a table cell dynamically change. And if the number or text does not fit into the cell, it was cut off in the middle with an ellipsis, and the letters or numbers that extreme from it hidden or appeared entirely when resizing?

OA210815LXRR1I OA210...LXRR1I OA2...RR1I

I'd like to create something like this: js fiddle

but I don't know how to fix the letter clipping problem when you resize

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

0

Try to do this :

    var MaxLen = 10;
    var limiLen = 5;
    var text = document.getElementById("text-test");
    
    if (text.innerHTML.trim().length > MaxLen) {
      var newTest =
        text.innerHTML.trim().substr(0, limiLen) +
        "..." +
        text.innerHTML
          .trim()
          .substr(text.innerHTML.trim().length - limiLen, limiLen);
    
      text.innerHTML = newTest;
    }
<html>
<head>
  <title> Response </title>
  <meta charset="UTF-8" />
</head>

<body>
  <div>
    <p id="text-test"> ABCDEFGHIJKLMNOPQRSTUVWXYZ </p>
  <div> 
  <script src="index.js">
  </script>
</body>
</html>

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