if anyone knows is plug-in who can find links on div and make clickable? I have div with text:
<div id="mytext">Wow, please go to http://www.google.com - this is my home page ;)</div>
And I want make automatic clickable links.
if anyone knows is plug-in who can find links on div and make clickable? I have div with text:
<div id="mytext">Wow, please go to http://www.google.com - this is my home page ;)</div>
And I want make automatic clickable links.
An easy to follow implementation:
var url_pattern = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
var content = $("#mytext").text();
var newContent = content.replace(url_pattern, function (link) {
return '<a href="' + link + '" target="_blank">' + link + '</a>';
});
$('#mytext').html(newContent);