Radio typeProperty

Radio 对象参考手册Radio Object

Definition and Usage

The type property returns the form element type of the radio button.

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

Syntax

radioObject.type


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the type property


Example

Example

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

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</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()">Show input type</button>

</body>
</html>

Try it Yourself »


Radio 对象参考手册Radio Object Other Extensions