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

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

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