Javascript DOM HTML Quote Object get

Introduction

The Quote object represents an HTML <q> element.

We can access a <q> element via document.getElementById():

var x = document.getElementById("myQuote");

Click the button to get the URL of the quotation.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p>Here is a quote from java2s.com's website:</p>

<p>This is a test:
<q id="myQuote" cite="http://www.java2s.com">
Test test test test.</q>
This is a test. This is a test. This is a test. 
</p>/*from   ww  w  .j  a  va  2  s.c o m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myQuote").cite;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related