这就是你需要的:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function createLinks(){
$('p, td').filter(function() {
return this.innerHTML.match(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/);
}).each(function(){
var link = $('<a>', { href: this.innerHTML,
text: this.innerHTML });
if(this.tagName == "P")
this.parentNode.replaceChild(link[0], this);
else{
this.removeChild(this.childNodes[0])
this.appendChild(link[0]);
}
});
}
$(document).ready(function(){
$('#create_links').click(function(){
createLinks();
});
});
</script>
<style>
a{
display:block;
}
</style>
</head>
<body>
<p>This shouldn't became a link</p>
<p>http://www.thisshouldbecamealink.com</p>
<p>http://www.anotherlink.com</p>
<table>
<tr>
<td>Not a link</td>
</tr>
<tr>
<td>http://www.validlink.com</td>
</tr>
</table>
<button id="create_links">Create links</button>
</body>
</html>