- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM blockquote object
The HTML DOM blockquote basically represent the HTML element <blockquote>. The <blockquote> element does not add any quotation marks unlike the <q> tag. We can create and access <blockquote> properties with the help of the blockquote object.
Syntax
Following is the syntax for −
Creating the blockquote object −
var x = document.createElement("BLOCKQUOTE");
Example
Let us see an example of the blockquote object −
<!DOCTYPE html> <html> <body> <p>Click on the below button to create a blockquote object</p> <button onclick="createBloc()">CREATE</button> <script> function createBloc() { var x = document.createElement("BLOCKQUOTE"); var t = document.createTextNode("This is a random block quote.This is some sample text."); x.setAttribute("cite", "http://www.examplesite.com"); x.setAttribute("id", "myQuote"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>
Output
This will produce the following output −
On clicking CREATE −
In the above example −
First, we have created a button CREATE to call createBloc() function.
<button onclick="createBloc()">CREATE</button>
The function createBloc() uses the createElement() method of the document object to create a <blockquote> element. Then using the createTextNode() method of the document object we created a text node with some text inside it. Using the setAttribute() method we add some attributes like cite, and id to the above created <blockquote>element. The element is then finally appended as a child to the document body using its appendChild() method.
function createBloc() { var x = document.createElement("BLOCKQUOTE"); var t = document.createTextNode("This is a random block quote.This is some sample text."); x.setAttribute("cite", "http://www.examplesite.com"); x.setAttribute("id", "myQuote"); x.appendChild(t); document.body.appendChild(x); }