Checkbox type 屬性

定義和用法
type 屬性可返回元素的表單類型。
對於一個 checkbox 對象,該屬性總是返回 "checkbox"。
語法
checkboxObject.type
流覽器支持
所有主要流覽器都支持 type 屬性
實例
實例
下麵的例子返回了 checkbox 的表單元素類型:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function displayResult(){
var x=document.getElementById("check1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="check1">你喜歡夏天嗎?
</form>
<button type="button" onclick="displayResult()">顯示 input 類型</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function displayResult(){
var x=document.getElementById("check1").type;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="check1">你喜歡夏天嗎?
</form>
<button type="button" onclick="displayResult()">顯示 input 類型</button>
</body>
</html>
