Easy Tutorial
❮ Dom Obj Col Dom Obj Textarea ❯

Radio type Attribute


Definition and Usage

The type attribute returns the form element type of a radio button.

For radio buttons, this attribute is always "radio".

Syntax


Browser Support

All major browsers support the type attribute.


Example

The following example returns the form element type of a radio button:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function displayResult(){
    var x=document.getElementById("red").type;
    alert(x);
}
</script>
</head>
<body>

<form>
Which color do you prefer?<br>
<input type="radio" name="colors" id="red">Red<br>
<input type="radio" name="colors" id="blue">Blue<br>
<input type="radio" name="colors" id="green">Green
</form>
<button type="button" onclick="displayResult()">Display input type</button>

</body>
</html>

❮ Dom Obj Col Dom Obj Textarea ❯