W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h3>如何访问 SAMP 元素的演示</h3> <samp id="mySamp">Sample output from a computer program</samp> <p>单击按钮将格式化文本的颜色设置为红色。</p> <button onclick="myFunction()">试一试</button> <script> function myFunction() { var x = document.getElementById("mySamp"); x.style.color = "red"; } </script> </body> </html>