实例首页
自学教程
IT工具箱
源代码
下载代码
上下布局
点击运行 >
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS text-decoration-color 属性 实例 - 自学教程(runoops.com)</title> <style> p#myP { text-decoration: underline; } </style> </head> <body> <p id="myP"> Hello world! </p> <p>点击“试一试”按钮,改变下划线的颜色。</p> <button onclick="myFunction()">试一试</button> <script> function myFunction() { document.getElementById("myP").style.textDecorationColor = "red"; document.getElementById("myP").style.MozTextDecorationColor = "red"; // 针对 Firefox 的代码 } </script> <p><b>注意:</b>几乎所有的主流浏览器都不支持 textDecorationColor 属性。</p> <p><b>注意:</b>Firefox 支持另一个可替代该属性的属性,即 MozTextDecorationColor 属性。</p> </body> </html>
运行结果: