Created
February 21, 2014 15:18
-
-
Save carlesjove/9136052 to your computer and use it in GitHub Desktop.
Substitute With
This file contains hidden or 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( $ ){ | |
$.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