Created
January 4, 2011 19:47
-
-
Save niczak/765284 to your computer and use it in GitHub Desktop.
Two lines of JavaScript to convert @ names to Twitter profile links.
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 http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>@ Name Test</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> | |
<script type="text/javascript"> | |
function fnLink() | |
{ | |
$(".twitter").each(function() | |
{ | |
var name = $(this).text(); | |
$(this).html('<a href="http://twitter.com/'+name+'" target="_blank">'+name+'</a>'); | |
}); | |
} | |
</script> | |
</head> | |
<body> | |
<center> | |
<h2>This is some testing ...</h2> | |
<span class="twitter">@niczak</span> was walking to <span class="twitter">@Twitter</span> when he saw <span class="twitter">@PrncssKT</span> and decided to stop for lunch.<br /> | |
<br /><button type="button" onclick="fnLink()">Link Em!</button><br /> | |
</center> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment