Skip to content

Instantly share code, notes, and snippets.

@eveevans
Created March 13, 2012 21:03
Show Gist options
  • Save eveevans/2031570 to your computer and use it in GitHub Desktop.
Save eveevans/2031570 to your computer and use it in GitHub Desktop.
jquery extension for split element words into span
/*! split_in_span v1 | flasheves.com */
jQuery.fn.extend({
split_in_span: function(){
var arr = jQuery(this).text().split(' ');
var tamo = arr.length;
for(i=0;i<tamo;i++){ arr[i] = '<span>' + arr[i] + '</span>'; }
jQuery(this).html(arr.join(' '));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment