如何使用JavaScript设置文本装饰的颜色?
要设置文本装饰的颜色,请使用JavaScript中的textDecorationColor 属性。
示例
您可以尝试运行以下代码来更改文本装饰的颜色-
<!DOCTYPE html>
<html>
<body>
<div id = "myText"> This is demo text. </div> <br>
<button onclick = "display()"> Set Text Decoration </button>
<script>
function display() {
document.getElementById("myText").style.textDecoration = "underline";
document.getElementById("myText").style.textDecorationColor = "red";
}
</script>
</body>
</html>热门推荐
10 放假假期祝福语简短精辟
11 送教授贺卡祝福语简短
12 加油冬奥祝福语英文简短
13 元宵发客户祝福语简短
14 退伍祝福语老师简短
15 医美的祝福语大全简短
16 生日祝福语已婚朋友简短
17 女士简短祝福语大全集
18 退休祝福语简短独特老师