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>

輸出

這將產生以下輸出 -

單擊“獲取型別”按鈕 -

更新於: 19-2-2021

91 瀏覽

開啟你的職業

完成課程認證

立即開始
廣告
© . All rights reserved.