Skip to content

Instantly share code, notes, and snippets.

@carlesjove
Created February 21, 2014 15:18
Show Gist options
  • Save carlesjove/9136052 to your computer and use it in GitHub Desktop.
Save carlesjove/9136052 to your computer and use it in GitHub Desktop.
Substitute With
(function( $ ){
$.fn.substitute_with = function(r, w) {
$(this).html($(this).text().split(r).join(w));
return this;
};
})( jQuery );
// Usage example
jQuery(document).ready(function($){
// <p>La Casa</p>
$('p').substitute_with('a', 'AAAA');
// <p>LAAAA CAAAAsAAAA</p>
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment