查閱表單型態
document.form.elements[i].type 可查閱表單型態
程式碼如下:
<form name = "F">
<input type="button" value="Button"><br>
<input type="checkbox" value="Checkbox"><br>
<input type="radio" value="Radio"><br>
<input type="text" value="Text"><br>
</form>
<script>
var length = document.F.elements.length;
for (var i = 0; i < length; i++){
document.write("type of " + i + " is " + document.F.elements[i].type);
document.write("<br>");
}
</script>