如何用 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