Javascript DOM HTML Quote cite Property set

Introduction

Change the URL of a quotation:

document.getElementById("myQuote").cite = "http://www.example.com/";

Click the button below to change the value of the cite attribute of the quotation above.

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./*from  ww w.  j  av  a 2  s .c  o  m*/
</p>
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  document.getElementById("myQuote").cite = "http://www.example.com";
  document.getElementById("demo").innerHTML = "The value of the cite attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related