I have string in my text selector
<p> Lorem Ipsum http:facebook.com</p>
I need get result
<p>Lorem Ipsum <a href="http//:facebook.com">http:facebook.com</a></p>
How i can make that? It's need for http, www and https
I have string in my text selector
<p> Lorem Ipsum http:facebook.com</p>
I need get result
<p>Lorem Ipsum <a href="http//:facebook.com">http:facebook.com</a></p>
How i can make that? It's need for http, www and https
Define a id for your paragraph tag. and Get text of your paragraph tag in jquery and replace it with the link by following script
$(document).ready(function() {
var mystring = $('#paragraphId').text();
var url = 'http';
var urlend = '.com';
var pos1 = mystring.indexOf(url);
var pos2 = mystring.indexOf(urlend);
var urlstring = mystring.substring(pos1,pos2+4);
var substring1 = mystring.substring(0,pos1);
var substring2 = mystring.substring(pos2+4);
$('#paragraphId').text(substring1);
$('#paragraphId').append($("<a href='"+urlstring+"'></a>").text(urlstring));
$('#paragraphId').append(substring2);
});
<p id="paragraphId"> Lorem Ipsum http:facebook.com Lorem Ipsum</p>