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