运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript String Methods</h1> <h2>The fontcolor() Method</h2> <p id="demo1"></p> <p>The fontcolor() method is deprecated in JavaScript.</p> <p>Use a style attribute instead:</p> <p id="demo2"></p> <script> let text = "Hello World!"; let result = text.fontcolor("green"); document.getElementById("demo1").innerHTML = result; result = "<span style='color:green'>" + text + "</span>"; document.getElementById("demo2").innerHTML = result; </script> </body> </html>