.eq() | JQuery API Documentation
Có thể bạn quan tâm
Given a jQuery object that represents a set of DOM elements, the .eq() method constructs a new jQuery object from one element within that set. The supplied index identifies the position of this element in the set.
Consider a page with a simple list on it:
| 1 2 3 4 5 6 7 | <ul> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> <li>list item 4</li> <li>list item 5</li></ul> |
We can apply this method to the set of list items:
| 1 | $( "li" ).eq( 2 ).css( "background-color", "red" ); |
The result of this call is a red background for item 3. Note that the supplied index is zero-based, and refers to the position of the element within the jQuery object, not within the DOM tree.
Providing a negative number indicates a position starting from the end of the set, rather than the beginning. For example:
| 1 | $( "li" ).eq( -2 ).css( "background-color", "red" ); |
This time list item 4 is turned red, since it is two from the end of the set.
If an element cannot be found at the specified zero-based index, the method constructs a new jQuery object with an empty set and a length property of 0.
| 1 | $( "li" ).eq( 5 ).css( "background-color", "red" ); |
Here, none of the list items is turned red, since .eq( 5 ) indicates the sixth of five list items.
Từ khóa » Eq Jquery Là Gì
-
.eq() | Hàm JQuery | Tham Khảo JQuery | Học Web Chuẩn
-
:eq() | Tham Khảo JQuery | Học Web Chuẩn
-
.eq() Trong JQuery - Hoclaptrinh
-
Cách Dùng :eq() Selector Trong JQuery - Freetuts
-
Eq(index) Trong JQuery
-
JQuery :eq() Selector - W3Schools
-
Cách Dùng :eq() Selector Trong JQuery - NguyenGiaTech
-
Jquery — JQuery: Eq () So Với Get () - Tra-loi-cau-hoi-phat-trien
-
Sự Khác Biệt Giữa Get () Và Eq () Trong Jquery Là Gì?
-
Eq Selector - Selector Trong Jquery
-
Tương đương JS Thuần Túy Của Jquery Eq () - HelpEx
-
Eq Selector - Freetuts
-
Tìm Hiểu Về JQuery Part 4 - Viblo
-
Jquery Traversing - Thầy Long Web