I'm programming a social media engine and I'd like to use jQuery to automatically wrap all http and https links into an <a>
element.
This is what I've gotten to after a lot of Google searching:
$('*').each(function test() {
var str = $(this);
if(str.match("^http")) {
str.wrap("<a></a>");
}
});
But when I run the code, I get the following error in the log.
TypeError: str.match is not a function [Learn More]
What would be the best way to go about doing this?