Skip to content

Instantly share code, notes, and snippets.

@Saturate
Last active December 18, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saturate/5850080 to your computer and use it in GitHub Desktop.
Save Saturate/5850080 to your computer and use it in GitHub Desktop.
Hashtag Maker 3000

Will make some awesome hashtags, punk.

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script>
$(function () {
function capitalize(txt) {
return txt.replace(/[^\s]+/g, function(str){
return str.substr(0,1).toUpperCase()+str.substr(1).toLowerCase();
});
}
function makeHashtag(txt) {
var capTxt = capitalize(txt);
var hashtxt = "#" + capTxt.split(' ').join('');
return hashtxt;
}
$('#doit').on('click', function() {
var txt = $('#txt').val();
$('#output').html(makeHashtag(txt));
});
});
</script>
<meta charset=utf-8 />
<title>Make Hashtags</title>
</head>
<body>
<h2>Your text!</h2>
<input id="txt" type="text" value="Write your text here" /><button id="doit">Make it!</button>
<h2>Your Hashtag!</h2>
<div id="output"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment