replace(), JavaScript Method

The replace(), Method from JavaScript has various uses. In the example below, you'll see a practical application of this Method. Syntax: string.replace("WhatToReplace","Replacement") See the example below. Show / Hide Script Show / Hide Demo <head> <style type='text/css'> </style> <script type='text/javascript'> function inlocuiesc(){ tre=document.getElementById('inl').value var guc=tre.replace(/s/g,"WOW") document.getElementById('inl').innerHTML=guc } </script> </head> <body> <textarea id='inl' cols='32' rows='8'>this frienship is special to us...</textarea><br> <input type='button' value='Replace' onclick='inlocuiesc()'> </body> </html> When you will click the Replace button, the "s" letter will be replaced by "WOW". this frienship is special to us...