Javascript DOM HTML Input Radio Object get

Introduction

The Input Radio object represents an HTML <input> element with type="radio".

We can access an <input> element with type="radio" via document.getElementById():

var x = document.getElementById("myRadio");

Click the button to check the radio button.

View in separate window

<!DOCTYPE html>
<html>
<body>
Radio Button: <input type="radio" id="myRadio">
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from  w  w  w . j  av  a2  s .  c om*/
  var x = document.getElementById("myRadio");
  x.checked = true;
}
</script>

</body>
</html>



PreviousNext

Related