Computer >> Máy Tính >  >> Lập trình >> HTML

HTML DOM Input Loại email Thuộc tính

Thuộc tính loại Email đầu vào HTML DOM trả về / đặt loại Email đầu vào.

Cú pháp

Sau đây là cú pháp -

  • Giá trị chuỗi trả về
inputEmailObject.type
  • Cài đặt loại thành giá trị chuỗi
inputEmailObject.type = stringValue

Giá trị chuỗi

Đây, “stringValue” có thể như sau -

stringValue Chi tiết
email Nó xác định loại đầu vào là email
datetime-local Nó xác định loại đầu vào là datetime-local
radio Nó xác định loại đầu vào đó là radio
tel Nó xác định loại đầu vào đó là tel và bàn phím số được hiển thị cho đầu vào

Ví dụ

Hãy để chúng tôi xem ví dụ về Loại email đầu vào tài sản -

<!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>

Đầu ra

Điều này sẽ tạo ra kết quả sau -

Trước khi nhấp vào ‘Nhập gì?’ nút -

HTML DOM Input Loại email Thuộc tính

Sau khi nhấp vào ‘Nhập gì?’ nút -

HTML DOM Input Loại email Thuộc tính