HTML DOM 輸入搜尋型別屬性
HTML DOM 輸入搜尋型別屬性與具有 type=”search”屬性的 input 元素相關聯。它將始終為 input 搜尋元素返回搜尋。
語法
以下是搜尋型別屬性的語法 -
searchObject.type
示例
我們來看看輸入搜尋型別屬性的一個示例 -
<!DOCTYPE html>
<html>
<body>
<h1>Search type property</h1>
<form>
FRUITS: <input type="search" id="SEARCH1" name="fruits">
</form>
<p>Get the above element type by clicking the below button</p>
<button onclick="getType()">Get Type</button>
<p id="Sample"></p>
<script>
function getType() {
var t = document.getElementById("SEARCH1").type;
document.getElementById("Sample").innerHTML = "The type for the input field is : "+t;
}
</script>
</body>
</html>輸出
這將產生以下輸出 -

單擊“獲取型別”按鈕 -

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