Created
June 27, 2014 15:48
-
-
Save nsu/6a8467dc654f7ed4cb6b to your computer and use it in GitHub Desktop.
Put bacon in textareas
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
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