Skip to content

Instantly share code, notes, and snippets.

@apisandipas
Created December 9, 2013 19:31
Show Gist options
  • Save apisandipas/7879349 to your computer and use it in GitHub Desktop.
Save apisandipas/7879349 to your computer and use it in GitHub Desktop.
sarcasm.js
/*
* sarcasm
* https://github.com/stayclassytally/sarcasm
*
* Copyright (c) 2013 Bryan Paronto
* Licensed under the MIT license.
*/
(function($) {
// Collection method.
$.fn.sarcasm = function() {
this.each(function() {
var content = $(this).text().split('');
for (var i = 0; i < content.length; i++) {
if (i % 2 === 0){
content[i] = "<i>" + content[i] + "</i>";
}
}
$(this).html(content);
});
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment