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 3696992
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:48:21+00:00 2026-05-19T04:48:21+00:00

I have Html contents like <span> http://j.mp/eUcRNK </span> I want to hyperlink on above

  • 0

I have Html contents like

<span> 
 http://j.mp/eUcRNK
</span>

I want to hyperlink on above html text like this

<span>
    <a href="http://j.mp/eUcRNK" class="link" target="_blank">
    http://j.mp/eUcRNK
    </a>
</span>

How I can do that..

  • 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-19T04:48:23+00:00Added an answer on May 19, 2026 at 4:48 am
    $('span').html(function(i,txt){
       return $('<a>').text(txt).attr({'target':'_blank', 'href': txt }).addClass('link');
    });
    

    demo

    based on the comments below, I guess this solves it.

    $('span').html(function(i,txt){
       return replaceURLWithHTMLLinks(txt);
    });
    
    function replaceURLWithHTMLLinks(text) {
      var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
      return text.replace(exp,"<a class='link' href='$1' target='_blank' >$1</a>"); 
    }
    

    updated fiddle

    for jquery 1.3.2, just change the jQuery codes a bit.

    var span = $('span');
    span.html(replaceURLWithHTMLLinks(span.html()));
    

    another updated fiddle

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

Sidebar

Related Questions

I want to parse a html content that have something like this: <div id=sometext>Lorem<br>
I have some HTML that looks like this: <div class=product> Content In Here <div
For example I want to extract the text in this article HTML: <div class=description>
I have html like this: <div> <span style=display: inline-block;height:20px>20</span> <span style=display: inline-block;><img src=img/ex.png/></span> </div>
OK I have backgrounds set up like this: HTML <div id=container> <div id=content> CONTENT
I have this function that switches the HTML contents from one element on a
I have a piece of code VERY similar to this one http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailFetching I the
I have the following tag with a Html.TextBoxFor expression and I want the contents
I have the following html: <!DOCTYPE html> <html> <head> <script src=http://code.jquery.com/jquery-latest.js></script> </head> <body> <span>not
Like the title says, I want to have a HTML table that allows its

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.