Created
August 20, 2009 19:07
-
-
Save drench/171276 to your computer and use it in GitHub Desktop.
Add search-and-replace to textareas
This file contains 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(){ | |
var D=document; | |
var CI=function() { return D.createElement('input') }; | |
var SaR=function(ta) { | |
var f=ta.parentNode; | |
var s=CI();var r=CI();var b=CI(); | |
b.value='replace'; | |
s.type=r.type='text'; | |
b.type='button'; | |
b.onclick=function() { | |
ta.value=ta.value.replace(new RegExp(s.value,'g'),r.value); | |
}; | |
f.insertBefore(s,ta); | |
f.insertBefore(r,ta); | |
f.insertBefore(b,ta); | |
}; | |
var tas=D.getElementsByTagName('textarea'); | |
for(var i=0,T;T=tas[i];++i) { SaR(T); } | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment