Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

คุณสมบัติ type ของ HTML DOM Input Search


คุณสมบัติ type ของ HTML DOM Input search เกี่ยวข้องกับองค์ประกอบ input ที่มี type=”search” จะคืนค่า search เสมอสำหรับองค์ประกอบ input search

ไวยากรณ์

ไวยากรณ์สำหรับคุณสมบัติ type ของ search:

searchObject.type

ตัวอย่าง

มาดูตัวอย่างสำหรับคุณสมบัติ type ของ Input search:

<!DOCTYPE html> <html> <body> <h1>Search type property</h1> <form> FRUITS: <input type="search" id="SEARCH1" name="fruits"> </form> <p>ดึง type ขององค์ประกอบด้านบนโดยคลิกปุ่มด้านล่าง</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>

ผลลัพธ์

จะได้ผลลัพธ์ดังนี้:

คุณสมบัติ type ของ HTML DOM Input Search

เมื่อคลิกปุ่ม “Get Type”:

คุณสมบัติ type ของ HTML DOM Input Search