HTML DOM 引用物件


HTML DOM 引用物件表示 HTML 文件的 <q> 元素。

我們來建立一個 q 物件 −

語法

以下為語法 −

document.createElement(“Q”);

屬性

以下是引用物件的屬性 −

屬性說明
cite它返回和更改 HTML 文件中引用元素的 cite 屬性的值。

示例

讓我們看一個 HTML DOM 引用物件的示例 −

 現場演示

<!DOCTYPE html>
<html>
<head>
<style>
   body{
      text-align:center;
      background-color:#fff;
      color:#0197F6;
   }
   h1{
      color:#23CE6B;
   }
   .drop-down{
      width:35%;
      border:2px solid #fff;
      font-weight:bold;
      padding:8px;
   }
   .btn{
      background-color:#fff;
      border:1.5px dashed #0197F6;
      height:2rem;
      border-radius:2px;
      width:60%;
      margin:2rem auto;
      display:block;
      color:#0197F6;
      outline:none;
      cursor:pointer;
   }
   p{
      font-size:1.2rem;
      background-color:#db133a;
      color:#fff;
      padding:8px;
   }
</style>
</head>
<body>
<h1>DOM quote Object Demo</h1>
<button onclick="createQuote()" class="btn">Create a quote object</button>
<script>
   function createQuote() {
      var qElement = document.createElement("Q");
      qElement.innerHTML="WordPress is software designed for everyone, emphasizing accessibility,
      performance, security, and ease of use. We believe great software should work with minimum set
      up, so you can focus on sharing your story, product, or services freely. ";
      qElement.setAttribute("cite","https://wordpress.org/about/");
      document.body.appendChild(qElement);
   }
</script>
</body>
</html>

輸出

這將生成以下輸出 −

點選“建立引用物件”按鈕建立引用物件 −

更新日期:01-Jul-2020

103 次瀏覽

開啟你的 職業生涯

完成課程來獲得認證

開始吧
廣告