HTML <button> พิมพ์แอตทริบิวต์
ตัวอย่าง
องค์ประกอบปุ่มสองปุ่มที่ทำหน้าที่เป็นปุ่มส่งหนึ่งปุ่มและปุ่มรีเซ็ตหนึ่งปุ่ม (ในรูปแบบ):
<form action="/action_page.php" method="get">
<label for="fname">First name:</label>
<input type="text" id="fname"
name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<button type="submit" value="Submit">Submit</button>
<button type="reset" value="Reset">Reset</button>
</form>
ความหมายและการใช้งาน
แอตทริบิวต์type
ระบุประเภทของปุ่ม
เคล็ดลับ:ระบุแอตทริบิวต์ type สำหรับ
<button>
องค์ประกอบเสมอ เบราว์เซอร์ที่แตกต่างกันอาจใช้ประเภทเริ่มต้นที่แตกต่างกันสำหรับ
<button>
องค์ประกอบ
รองรับเบราว์เซอร์
Attribute | |||||
---|---|---|---|---|---|
type | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
<button type="button|submit|reset">
ค่าแอตทริบิวต์
Value | Description |
---|---|
button | The button is a clickable button |
submit | The button is a submit button (submits form-data) |
reset | The button is a reset button (resets the form-data to its initial values) |
❮ แท็ก HTML <button>