如何用 JavaScript 设置文本装饰中的线条类型?
要设置文本装饰中线条的类型,请使用 textDecorationLine 属性。你可以尝试运行以下代码,用 JavaScript 返回文本当中线条的类型 −
示例
<!DOCTYPE html>
<html>
<body>
<div id = "myText" style = "text-decoration: underline;">
This is demo text.
</div>
<br>
<button onclick="display()"> Set Text Decoration </button>
<script>
function display() {
document.getElementById("myText").style.textDecorationColor = "red";
document.getElementById("myText").style.textDecorationLine = "overline";
}
</script>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP