HTML DOM 輸入電子郵件型別屬性
HTML DOM 輸入電子郵件型別屬性返回/設定輸入電子郵件的型別。
語法
以下是語法 -
- 返回字串值
inputEmailObject.type
- 將 type 設定為字串值
inputEmailObject.type = stringValue
字串值
此處,“stringValue”可以是以下內容 -
| stringValue | 詳情 |
|---|---|
| 它定義輸入型別為電子郵件 | |
| datetime-local | 它定義輸入型別為 datetime-local |
| radio | 它定義輸入型別為單選按鈕 |
| tel | 它定義輸入型別為 tel,並且顯示數字鍵盤以供輸入 |
示例
讓我們看一個 輸入電子郵件型別 屬性的示例 -
<!DOCTYPE html>
<html>
<head>
<title>Input Email type</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Email-type</legend>
<label for="EmailSelect"></label>
<input type="email" id="EmailSelect" >
<input type="button" onclick="getTypeOfInput()" value="What to enter?">
</fieldset>
</form>
<script>
var labelSelect = document.querySelector("label");
var inputEmail = document.getElementById("EmailSelect");
function getTypeOfInput() {
labelSelect.innerHTML = inputEmail.type.toUpperCase()+' ID: ';
}
</script>
</body>
</html>輸出
這將產生以下輸出 -
在單擊 ‘What to enter?’ 按鈕之前 -

單擊 ‘What to enter?’ 按鈕之後 -

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP