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

99
Vistas
Convert text inside td with http to a link

I want to detect all links for all td with item-description class; How to make this work if my string is both just the link and when the description is link with other text. Here is my code but it does not work!

<script>
var items = document.getElementsByClassName("item-description");
for (var i = 0; i < items.length; i++) {
      var text = items[i].innerText;
      var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
      text.replace(exp, "<a href='$1' target='_blank'>$1</a>");
    }
</script>

It doesn't work as it is, the text in are generated from form submissions. Basically if the text of td is something.com I want to make that into an a tag inside the td. I also want it to work when the text is the link text with other text. Sample: https:something.com other text here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First of all a TD is a cell in a table.

The cell can have different elements in it, including the tag which can make it clickable.

However, due to the nature of a table-cell, the height and width of a cell does not depend only on its contents but also on its neighboring tags which can cause the clickable area to cover only a part of the cell.

Hence to make the entire link clickable, you will have to bind a JavaScript (JS) click event on that td to make it to redirect to another page or whatever link you want.

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