Replace all in div or textarea content using javascript To replace from div use(innerHTML) in javascript: <div id="ss">replace all with javascript</div> <button onclick="replaceall()">replaceAll</button> <script> function replaceall(){ var repall=document.getElementById("ss").innerHTML; var repall_1=repall.split(" ").join("-") document.getElementById("ss").innerHTML=repall_1 } </script> To replace from input or textarea use(value) in javascript: <textarea id="tex" style="width:100%">replace all with javascript</textarea> <button onclick="replaceall1()">replaceAll</button> <script> function replaceall1(){ var repall=document.getElementById("tex").value; var repall_1=repall.split(" ").join("-") document.getElementById("tex").value=repall_1 } </script> © Manajmnt code Share to : ☷✎ Comments
Comments
Post a Comment
message