如何使用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 60岁长辈祝福语简短
11 祝福语对联文案简短大气
12 送离职同事简短祝福语
13 给儿子生日祝福语 简短
14 新房开工文案祝福语简短
15 贺卡祝福语情侣搞笑简短
16 生日祝福语贺卡老师简短
17 恩师退休花束祝福语简短
18 生日祝福语简短明了 同事