把字符串转换为小写 - toLowerCase()
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 字符串方法</h1>
- <p>把字符串转换为小写:</p>
- <button onclick="myFunction()">试一试</button>
- <p id="demo">Hello World!</p>
- <script>
- function myFunction() {
- var text = document.getElementById("demo").innerHTML;
- document.getElementById("demo").innerHTML = text.toLowerCase();
- }
- </script>
- </body>
- </html>