HTML DOM blockquote cite 屬性與 HTML <blockquote> 元素相關聯。此屬性用於設置或返回引用的 cite 屬性。 cite 屬性對屏幕閱讀器很有用,但對普通用戶沒有太大用處,因為它在網頁上沒有任何視覺效果。 cite 屬性用於設置引用的源 url。
用法
以下是語法 -
設置引用屬性 -
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>
輸出
這將產生以下輸出 -
單擊更改 -
在上麵的例子中 -
我們采用了一個 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' "; }
相關用法
- HTML DOM blockquote用法及代碼示例
- HTML DOM blur()用法及代碼示例
- HTML DOM button用法及代碼示例
- HTML DOM Style overflowY屬性用法及代碼示例
- HTML DOM Document hidden屬性用法及代碼示例
- HTML DOM IFrame用法及代碼示例
- HTML DOM Textarea cols屬性用法及代碼示例
- HTML DOM Style pageBreakAfter屬性用法及代碼示例
- HTML DOM Base href屬性用法及代碼示例
- HTML DOM Pre用法及代碼示例
- HTML DOM Input Month用法及代碼示例
- HTML DOM Video canPlayType()用法及代碼示例
- HTML DOM Range deleteContents()用法及代碼示例
- HTML DOM console.dirxml()用法及代碼示例
- HTML DOM Style transition屬性用法及代碼示例
- HTML DOM Video volume屬性用法及代碼示例
- HTML DOM Input Range用法及代碼示例
- HTML DOM Style outlineOffset屬性用法及代碼示例
- HTML DOM Storage setItem()用法及代碼示例
- HTML DOM TableHeader用法及代碼示例
注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 HTML DOM blockquote cite Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。