ข้อมูลอ้างอิงHTML

HTML โดยตัวอักษร HTML ตามหมวดหมู่ รองรับ HTML Browser แอตทริบิวต์ HTML HTML Global Attributes เหตุการณ์ HTML HTML สี HTML Canvas HTML เสียง/วิดีโอ ชุดอักขระ HTML HTML Doctypes การเข้ารหัส URL HTML รหัสภาษา HTML รหัสประเทศ HTML ข้อความ HTTP วิธี HTTP ตัวแปลง PX เป็น EM แป้นพิมพ์ลัด


HTML <button> พิมพ์แอตทริบิวต์

❮ แท็ก 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>