Javascript DOM HTML Fieldset Object create

Introduction

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

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

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

View in separate window

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

<script>
function myFunction() {/*from www.  j a  v a2s .  c om*/
  var x = document.createElement("FIELDSET");
  var t = document.createTextNode("Insert content here...");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related