Javascript Reference - HTML DOM Blockquote Object








The Blockquote object represents an HTML <blockquote> element.

Blockquote Object Properties

Property Description
cite Sets or gets the value of the cite attribute

Standard Properties and Events

The Blockquote object supports the standard properties and events.

Example

The following code shows how to get a <blockquote> element by using getElementById().


<!DOCTYPE html>
<html>
<body>
<blockquote id="myBlockquote" cite="http://www.java2s.com">HTML tutorial
</blockquote>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from   w  w  w  . j a v a2  s  . c o m-->
    var x = document.getElementById("myBlockquote").cite;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to create a <blockquote> element by using the document.createElement() method.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--  www. ja v a  2 s. com-->
    var x = document.createElement("BLOCKQUOTE");
    var t = document.createTextNode("HTML tutorial");
    x.setAttribute("cite", "http://www.java2s.com");
    x.appendChild(t);
    document.body.appendChild(x);
}
</script>

</body>
</html>

The code above is rendered as follows: