ในการกำหนดรูปแบบของบรรทัดใน JavaScript ให้ใช้ textDecorationStyle คุณสมบัติ. คุณสามารถตั้งค่าขีดเส้นใต้ คู่ หรือขีดเส้นใต้ ฯลฯ สำหรับลักษณะเส้นได้
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อส่งคืนสไตล์ของบรรทัดในการตกแต่งข้อความด้วย 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.textDecorationStyle = "double";
}
</script>
</body>
</html>