Created
August 10, 2011 18:01
-
-
Save sdball/1137643 to your computer and use it in GitHub Desktop.
Text into a link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Text to Link</title> | |
</head> | |
<body> | |
<h1>Text into Link</h1> | |
<table border="1" cellspacing="5" cellpadding="5"> | |
<tr><th>xyzzyb was just text</th></tr> | |
<tr><td>xyzzyb is the magic word</td></tr> | |
</table> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
jQuery(document).ready(function($) { | |
$('table td').each(function(index) { | |
// just an example regex with capturing | |
$(this).html($(this).html().replace(/(x.z{2}.b)/, '<a href="http://xyzzyb.com">$1</a>')); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment