Javascript DOM HTML Strong Object create

Introduction

We can create a <strong> element via the document.createElement() method:

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

Click the button to create a STRONG element with some text.

View in separate window

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

<script>
function myFunction() {/*from ww w. ja v  a  2s.com*/
  var x = document.createElement("STRONG");
  var t = document.createTextNode("Some strong text");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related