Hierarchy Selectors


SelectorExampleDescription
parent > child$("ul > li")Selects all <li> elements that are direct child of their parent <ul> element.
ancestor descendant$("form label")Selects all <label> elements that are descendant of their ancestor <form> element.
prev + next$("h1 + p")Selects all <p> elements that are next i.e. immediately preceded to the <h1> elements.
prev ~ siblings$("h1 ~ p")Selects all <p> elements that are siblings and follow after the <h1> elements.

Leave a Reply

Your email address will not be published. Required fields are marked *