Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 453543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:10:57+00:00 2026-05-12T22:10:57+00:00

I want to replace a link with its innerHTML, how is it done? Example:

  • 0

I want to replace a link with its innerHTML, how is it done?

Example:

Bla bla bla <a href="#nogo">No link here</a> bla bla bla

has to become

Bla bla bla No link here bla bla bla

Tried to replace the node with its innerHTML but I can’t get the text in the node itself..

I guess I have to work with regular expressions but I can’t figure out how.

EDIT: Thank you all for the quick responses! I still can’t seem to get it right. It looks like there’s more going on.

I am using prototype js as well.

I got some text with could contain a link. If the text contains a link it should be replaced by it’s innerHTML.
It looks something like this:

<td id="text">This is some text <a href="/link/Go_%28To%29" title="Go (to)">goto</a>. Some more text.</td>

I tried using hasChildNodes() to check wether the text contained a link but it always returns yes, even when the text did not contain a link or other element. So I thought that maybe the text is considered a node too and tried childElements[1]. That returns undefined. So maybe the link is a node of the textnode then. Nothing!
I am scraping this data and evalling the JSON so the weirdness may come from that. Walking the DOM in the rest of the response goes well though..

However when I alert

$('text').childElements()[0]

The actual href get’s alerted! (localhost//link/Go_%28To%29)

$(‘text’.childElements()[0].up() gets me to the actual td parent element.

So I am using

if($('text').childElements()[0])

To check wether the text contains a link.

I guess this gets a bit off-topic but I actually can’t get the a element right. Any tips?
Maybe a regexp is the best option?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:10:58+00:00Added an answer on May 12, 2026 at 10:10 pm

    In the end I solved the problem with an ugly replace(/<\/?[^>]+(>|$)/g, "\n"). There were a lot of other things going on which I haven’t documented well, my fault.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 440k
  • Answers 440k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You must put commas between all the arguments. Change: SELECT… May 15, 2026 at 5:22 pm
  • Editorial Team
    Editorial Team added an answer The path should be relative to the root of your… May 15, 2026 at 5:22 pm
  • Editorial Team
    Editorial Team added an answer Try to use WinAPI CreateEvent function May 15, 2026 at 5:22 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.