如何使用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 良师益友祝福语简短