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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:18:53+00:00 2026-06-09T08:18:53+00:00

I am pulling in tweets through a getJSON and writing them to a Google

  • 0

I am pulling in tweets through a getJSON and writing them to a Google map infowindow with javascript. The problem is, these tweets come with text links but no formatting (and no ids/classes/anything for which to narrow a find and replace). This is the mash of code I’m using right now to find the text, but I can’t get it to wrap whatever it finds in <a> tags to properly display the links:

function wrap( str ) {
    return '<a href="' + str + '">' + str + '<\/a>';
};

function replaceText() {
    var jthis = $(this);
    $("*").each(function () {
        if (jthis.children().length == 0) {
            jthis.text(jthis.text().replace(/\bhttp[^ ]+/i, wrap));
        }
    });
}
$(document).ready(replaceText);
$("html").ajaxStop(replaceText);

Did I overlook something or does anyone know a better way to do this?

  • 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-06-09T08:18:54+00:00Added an answer on June 9, 2026 at 8:18 am

    If i understand your problem right, this should work.
    not sure why you are iterating through elements as regexp will scan all the text anyway.

    <html>
        <head>
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js" type="text/javascript"></script>
            <script>
            function wrap( str ) {
                return '<a href="' + str + '">' + str + '<\/a>';
            };
            function replaceText() {
                $(".tweet").each( function(){
                  $(this).html($(this).html().replace(/\bhttp[^ ]+/ig, wrap));
                })
    
            }
            $(document).ready(replaceText);
            </script>
        </head>
        <body>
            <div class="tweet"> test 1 http://example.com/path </div>
            <div class="tweet"> test 2 http://example.com/path </div>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pulling data out of a Google doc, processing it, and writing it to
im pulling in images from the net, and want to manipulate them a bit
Im pulling a text file - it will be input by user currently its
I am currently pulling an XML feed into a webapp through ajax. Obviously i
I'm having trouble pulling text from Excel, it is pulling it correctly as far
I have a Java project where I am pulling tweets from twitter using the
im pulling my hair out. im utilising mod_rewrite to run through index.php if %{REQUEST_URI}
I'm pulling in tweets for my application and I want to be able to
Currently pulling out ma hair over the following problem. My code adds Rectangle s
I have cgi script pulling search terms from an HTML form through CGI::Ajax .

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.