Javascript DOM HTML Blockquote Object create

Introduction

We can create a <blockquote> element by using the document.createElement() method:

var x = document.createElement("BLOCKQUOTE");

Click the button to create a BLOCKQUOTE element with a link to java2s.com as the source of the quotation.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from  w ww .j  av  a  2  s . c  o  m*/
  var x = document.createElement("BLOCKQUOTE");
  var t = document.createTextNode("This is a test.");
  x.setAttribute("cite", "https://www.java2s.com");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related