Ist there any better way to replace/wrap the h*tp://name.tld/request_url?parameter or h*tps://name.tld/request_url?parameter text in some certain html elements with an <a href>
HTML
<div id="posts">
<div class="post">
Tweet text 1 http://google.com and other text.
</div>
<div class="post">
Tweet text 2 https://www.google.com and other text.
</div>
<div class="post">
Tweet text 3
</div>
<div class="post">
...
</div>
</div>
JavaScript
jQuery('#posts .post').each( function () {
elem = jQuery(this);
elem.html(
elem.text()
.replace(/(http?:\/\/?\S+)/g, "<a href='$1'>$1</a>")
);
});
Any jQuery.wrap() alternative would be nice too...