HTML DOM blockquote cite 屬性
HTML DOM blockquote cite 屬性與 HTML <blockquote> 元素關聯。此屬性用於設定或返回引用的 cite 屬性。cite 屬性對於螢幕閱讀器很有用,但對於普通使用者來說並不是很有用,因為它對網頁沒有任何視覺效果。cite 屬性用於設定引用的來源 URL。
語法
以下是語法 −
設定 cite 屬性 −
blockquoteObject.cite = URL
此處,URL 指定引文所在位置。
範例
我們來看看 blockquote cite 屬性的示例 −
<!DOCTYPE html>
<html>
<body>
<h2>Quote</h2>
<p>Here is a quote:</p>
<blockquote id="myBlockquote" cite="www.webexample.com">
Here is some sample text in place of quote.
</blockquote>
<p>Click the button below to change the above quote cite value.</p>
<button onclick="citeChange()">CHANGE</button>
<p id="Sample"></p>
<script>
function citeChange() {
document.getElementById("myBlockquote").cite = "http://www.examplesite.com";
document.getElementById("Sample").innerHTML = "The value of the cite attribute was
changed to 'www.examplesite.com' ";
}
</script>
</body>
</html>輸出
這會產生以下輸出 −

點選 CHANGE −

在上面的示例中 −
我們取了一個具有 id “myBlockquote” 的 <blockquote> 元素,cite 屬性值為 webexample −
<blockquote id="myBlockquote" cite="www.webexample.com"> Here is some sample text in place of quote. </blockquote>
然後我們有一個按鈕 CHANGE 來執行 citeChange() 函式 −
<button onclick="citeChange()">CHANGE</button>
citeChange() 函式獲取具有 “myBlockquote” id 的元素,並獲取其 cite 屬性,並將其更改為 “www.examplesite.com”。在更改 cite 值後,訊息 “The value of the cite attribute was changed to 'www.examplesite.com' ” 顯示在與其關聯的 id 為 “Sample” 的段落中。
function citeChange() {
document.getElementById("myBlockquote").cite = "http://www.examplesite.com";
document.getElementById("Sample").innerHTML = "The value of the cite attribute was changed to 'www.examplesite.com' ";
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP