文字列置き換え(replace)
<html> <head> <title>赤ちゃん言葉に変換</title> <script language="JavaScript"> <!-- function baby() { text = document.form1.text.value; text = text.replace("です", "でちゅ"); text = text.replace("ます", "まちゅ"); document.form1.text.value = text; } //--> </script> </head> <body> <form name="form1"> <h1 style="font-size:20px">赤ちゃん言葉に変換</h1> <textarea name="text" rows="20" cols="70"></textarea><br> <br> <input type="button" onClick="baby()" value=" 変 換 "> </form> </body> </html>
〔 実行する 〕