Skip to content

Instantly share code, notes, and snippets.

@nsu
Created June 27, 2014 15:48
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 nsu/6a8467dc654f7ed4cb6b to your computer and use it in GitHub Desktop.
Save nsu/6a8467dc654f7ed4cb6b to your computer and use it in GitHub Desktop.
Put bacon in textareas
function setText(textarea) {
jQuery.getJSON('//baconipsum.com/api/?callback=?',
{ 'type':'meat-and-filler', 'start-with-lorem':'1', 'sentences':Math.floor((Math.random() * 3) + 1) },
function(baconGoodness)
{
if (baconGoodness && baconGoodness.length > 0)
{
textarea.value = baconGoodness;
}
}
);
};
jQuery(function(){
jQuery("textarea").each(function(){
setText(this);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment