Child Filter Selectors


SelectorExampleDescription
:first-child$("p:first-child")Selects all <p> elements that are the first child of their parent.
:last-child$("p:last-child")Selects all <p> elements that are the last child of their parent.
:nth-child(n)$("p:nth-child(3)")Selects all <p> elements that are the 3rd child of their parent.
:only-child$("p:only-child")Selects all <p> elements that are the only child of their parent.
:first-of-type$("p:first-of-type")Selects all <p> elements that are the first <p> element of their parent.
:last-of-type$("p:last-of-type")Selects all <p> elements that are the last <p> element of their parent.
:only-of-type$("p:only-of-type")Selects all <p> elements that have no siblings with the same element name.
:nth-last-child(n)$("p:nth-last-child(3)")Selects all <p> elements that are the 3rd-child of their parent, counting from the last element to the first.
:nth-of-type(n)$("p:nth-of-type(2)")Selects all <p> elements that are the 2nd <p> element of their parent
:nth-last-of-type(n)$("p:nth-last-of-type(2)")Selects all <p> elements that are the 2nd-child of their parent, counting from the last element to the first.

Leave a Reply

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