Computer >> 컴퓨터 >  >> 프로그램 작성 >> HTML

HTML DOM 스타일 textDecorationColor 속성


DOM 스타일 textDecorationColor 속성은 HTML 문서에 있는 요소의 텍스트 장식 색상을 반환하고 수정합니다.

구문

다음은 구문입니다 -

  • textDecorationColor 반환

object.style.textDecorationColor
  • textDecorationColor 수정

object.style.textDecorationColor = “color”

예시

스타일 textDecorationColor 속성의 예를 살펴보겠습니다 -

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      color: #000;
      background: lightblue;
      height: 100vh;
   }
   p {
      margin: 1.5rem auto;
      text-decoration: line-through;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
   }
</style>
</head>
<body>
<h1>DOM Style textDecorationColor Property Example</h1>
<p>This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text.</p>
<button onclick="add()" class="btn">Change textDecorationColor</button>
<script>
   function add() {
      document.querySelector('p').style.textDecorationColor = "#db133a";
   }
</script>
</body>
</html>

출력

이것은 다음과 같은 출력을 생성합니다 -

HTML DOM 스타일 textDecorationColor 속성

"textDecorationColor 변경을 클릭합니다. " 버튼을 눌러 단락 텍스트의 선 색상을 변경합니다.

HTML DOM 스타일 textDecorationColor 속성