如何用 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
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP