HTML DOM 下劃線物件


HTML DOM 下劃線物件在 HTML 中表示 <u> 元素。

建立一個 <u> 元素

var uObject = document.createElement(“U”)

讓我們看看一個 下劃線 元素示例 -

示例

 即時演示

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Underline</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
   <form>
      <fieldset>
         <legend>HTML-DOM-Underline</legend>
         <h2 ><u id="Underline">Warning: </u>This is a Demo Example</h2>
         <input type="button" value="Show" onclick="getBetterDisp()">
      </fieldset>
   </form>
<script>
   var uObject = document.getElementById("Underline");
   function getBetterDisp() {
      uObject.style.backgroundColor = '#DC3545';
      uObject.style.color = '#FFF';
   }
</script>
</body>
</html>

輸出

點選 顯示 按鈕前 -

點選 顯示 按鈕後 -

更新於: 2019 年 10 月 30 日

145 次瀏覽

開啟您的 職業生涯

完成課程認證

開始
廣告
© . All rights reserved.