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

154
Views
Reemplace el final del texto HTML con algunos puntos

Tengo el siguiente marcado:

 <h5> <a href="javascript:void(0);">I am a very long title and I need to be shortened</a> </h5>

¿Cómo puedo hacer que si el texto h5 está por encima de un cierto número de caracteres, me deshago de los otros caracteres y los reemplazo con un "..."?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Esto debería funcionar. Tienes que mostrar el elemento en línea como un bloque.

Editar : me acabo de dar cuenta de que desea agregar puntos si el H5 excede una cantidad de caracteres, no si excede un ancho. Creo que para hacer eso necesitará usar JS; consulte la otra respuesta para eso.

 h5 { display: block; white-space: nowrap; width: 12em; overflow: hidden; text-overflow: ellipsis; color: red; /* This needs to match the color of the anchor tag */ } a:link { color: red; }
 <h5> <a href="javascript:void(0);">I am a very long title and I need to be shortened</a> </h5>

over 4 years ago · Santiago Trujillo Report

0

Puedes hacerlo:

 var name = $('a').text(); if (name.length > 20) { var shortname = name.substring(0, 20) + " ..."; $('a').replaceWith(shortname); }
over 4 years ago · Santiago Trujillo Report

0

Si desea utilizar JavaScript, puede ampliar el objeto String mediante la creación de prototipos:

 String.prototype.limit = function(length) { return this.length > length ? (this.substring(0, length) + '...') : this; } var str = 'qwertyuiop'; console.log(str.limit(5)); // qwert...
over 4 years ago · Santiago Trujillo 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!