HTML DOM tabIndex Property
Thí dụ
Thay đổi thứ tự tab cho ba liên kết:
document.getElementById("myAnchor1").tabIndex = "3";
document.getElementById("myAnchor2").tabIndex = "2";
document.getElementById("myAnchor3").tabIndex = "1";
Thêm các ví dụ "Hãy tự mình thử" bên dưới.
Định nghĩa và Cách sử dụng
Thuộc tính tabIndex đặt hoặc trả về giá trị của thuộc tính tabindex của một phần tử.
Thuộc tính tabindex chỉ định thứ tự tab của một phần tử (khi nút "tab" được sử dụng để điều hướng).
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
tabIndex | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Trả lại thuộc tính tabIndex:
HTMLElementObject.tabIndex
Đặt thuộc tính tabIndex:
HTMLElementObject.tabIndex = number
Giá trị tài sản
Value | Description |
---|---|
number | Specifies the tabbing order of the element (1 is first). Note: If the number is negative, the element will be removed from the tab order |
Chi tiết kỹ thuật
Giá trị trả lại: | Một Số, đại diện cho thứ tự tab của phần tử |
---|
Các ví dụ khác
Thí dụ
Nhận thứ tự tab của phần tử <a> đầu tiên (chỉ mục 0) trong tài liệu:
var x = document.getElementsByTagName("A")[0].tabIndex;
document.getElementById("demo").innerHTML = x;
Các trang liên quan
Tham chiếu HTML: Thuộc tính HTML tabindex
❮ Đối tượng phần tử