title: wrapping a text url with <a> tags via jquery find and replace
body: <p>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 <code>&lt;a&gt;</code> tags to properly display the links:</p>
  
  <pre><code>function wrap( str ) {
      return '&lt;a href="' + str + '"&gt;' + str + '&lt;\/a&gt;';
  };
  
  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);
  </code></pre>
  
  <p>Did I overlook something or does anyone know a better way to do this?</p>