The Quote object represents an HTML <q> element.
The Quote object supports the standard properties and events.
Property | Description |
---|---|
cite | Sets or gets the cite attribute of a quotation |
We can access a <q> element by using getElementById().
<!DOCTYPE html>
<html>
<body>
<q id="myQuote" cite="http://www.example.com">quote</q>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from ww w .j av a 2s .co m-->
var x = document.getElementById("myQuote").cite;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
We can create a <q> element by using the document.createElement() method.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- w w w. ja v a 2s.c o m-->
var x = document.createElement("QUOTE");
var t = document.createTextNode("text");
x.setAttribute("cite", "http://www.example.com");
x.appendChild(t);
document.body.appendChild(x);
}
</script>
</body>
</html>
The code above is rendered as follows: