jquery siblings 1

jquery siblings

$( "li.third-item" ).siblings().css( "background-color", "red" );

Here is what the above code is Doing:
1. Selects the first list item within the unordered list.
2. Selects the list item with the class “third-item” within the unordered list.
3. Selects the list item with the class “third-item” within the unordered list and selects all of the list items that come after it.
4. Selects the list item with the class “third-item” within the unordered list and selects all of the list items that come before it.
5. Selects the list item with the class “third-item” within the unordered list and selects all of the list items that are siblings of it.

Similar Posts