jQuery: siblings

This entry is part 30 of 33 in the series jQuery Tutorial

The siblings method allows us to search through the siblings of these elements in the DOM tree and construct a new jQuery object from the matching elements.

<!doctype html>
    <title>eq demo</title>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
        li {
            background: yellow;

        .silver {
            background: silver;

    <li>list item 1</li>
    <li>list item 2</li>
    <li class='third-item'>list item 3</li>
    <li>list item 4</li>
    <li>list item 5</li>




Notice that list items 1, 2, 4 and 5 are selected but not list item 3.

Series Navigation<< jQuery: .filter()
jQuery: not >>

Leave a comment

Leave a Reply