Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created July 23, 2010 14:47
Show Gist options
  • Select an option

  • Save cowboy/487528 to your computer and use it in GitHub Desktop.

Select an option

Save cowboy/487528 to your computer and use it in GitHub Desktop.
jQuery replaceText - textarea support (?)
// 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 );
});
@ssbarnea
Copy link

ssbarnea commented May 7, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment