Created
July 23, 2010 14:47
-
-
Save cowboy/487528 to your computer and use it in GitHub Desktop.
jQuery replaceText - textarea support (?)
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
| // If you want jQuery replaceText to be able to replace modified content | |
| // inside a textarea, you might need to do this kind of thing, since | |
| // changing the textarea .value doesn't change the textarea's child text | |
| // node! | |
| $('textarea') | |
| .each(function(){ | |
| $(this).html( this.value ).val( this.value ); | |
| }) | |
| .replaceText( /\btext\b/gi, 'TEXT' ) | |
| .each(function(){ | |
| $(this).html( this.innerHTML ).val( this.innerHTML ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
transform this into a pull request to the library but make the functionality optional as by default most people would not want to touch textarea contents.