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