Will make some awesome hashtags, punk.
Last active
December 18, 2015 21:49
-
-
Save Saturate/5850080 to your computer and use it in GitHub Desktop.
Hashtag Maker 3000
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> | |
<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