Input Text type 属性
查看文本域是属于哪种表单元素类型:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>蜜蜂教程(mifengjc.com)</title>
<script>
function displayResult() {
var x = document.getElementById("email").type;
alert(x);
}
</script>
</head>
<body>
<form>
Email: <input type="text" id="email">
</form>
<button type="button" onclick="displayResult()">显示 input 类型</button>
</body>
</html>
定义和用法
type 属性返回文本域的表单元素类型。
对于文本域,该属性总是返回 "text"。
浏览器支持
![]()
![]()
![]()
![]()
![]()
所有主流浏览器都支持 type 属性
语法
textObject.type
返回值
| 类型 | 描述 |
|---|---|
| String | 文本域的表单元素类型 |
Input Text 对象
Input Text 对象