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

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

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