คุณสมบัติประเภทการค้นหาอินพุต HTML DOM เชื่อมโยงกับองค์ประกอบอินพุตที่มีประเภท =” ค้นหา” มันจะส่งคืนการค้นหาองค์ประกอบการค้นหาอินพุตเสมอ
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์สำหรับคุณสมบัติประเภทการค้นหา -
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> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

เมื่อคลิกปุ่ม "รับประเภท" -
