Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. Selecting Elements with jQuery > Selecting Specific Siblings

2.3. Selecting Specific Siblings

2.3.1. Problem

You need to select only a specific set of siblings of a particular element.

2.3.2. Solution

If you’re looking to select the adjacent sibling of a particular element, then you can use the adjacent sibling combinator (+). Similar to the child (>) combinator, the sibling combinator expects a selector expression on each side. The righthand expression is the subject of the selector, and the lefthand expression is the sibling you want to match. Here’s some example HTML markup:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial