替换字符串中的字符 - replace()

  1. <html>
  2. <body>
  3.  
  4. <script type="text/javascript">
  5.  
  6. var str="Visit Microsoft!"
  7. document.write(str.replace(/Microsoft/,"yousite"))
  8.  
  9. </script>
  10. </body>
  11. </html>