HTML <button> loại Thuộc tính
Thí dụ
Hai phần tử nút hoạt động như một nút gửi và một nút đặt lại (trong một biểu mẫu):
<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>
Định nghĩa và Cách sử dụng
Thuộc type
tính chỉ định loại nút.
Mẹo: Luôn chỉ định thuộc tính type cho
<button>
phần tử. Các trình duyệt khác nhau có thể sử dụng các kiểu mặc định khác nhau cho
<button>
phần tử.
Hỗ trợ trình duyệt
Attribute | |||||
---|---|---|---|---|---|
type | Yes | Yes | Yes | Yes | Yes |
Cú pháp
<button type="button|submit|reset">
Giá trị thuộc tính
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) |
❮ Thẻ HTML <button>