Javascript DOM HTML Input Radio Object create

Introduction

We can create an <input> element with type="radio" via the document.createElement() method:

Click the button to create a Radio Button.

View in separate window

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

<script>
function myFunction() {/*from   w  w  w .  ja  v a2  s .co  m*/
  var x = document.createElement("INPUT");
  x.setAttribute("type", "radio");
  document.body.appendChild(x);
}
</script>

</body>
</html>



PreviousNext

Related