Quick Reference
This is a quick reference list of jQuery selectors and how they work in selecting HTML elements to apply scripting.
- jQuery – * SelectorThe * selector selects all HTML elements in the document, and if used together with another element can be used to select all that element’s child elements.
- jQuery – :animated SelectorThe :animated selector selects all HTML elements that are currently animated.
- jQuery – [attribute] SelectorThe selector selects every HTML element with the specified attribute.
- jQuery – [attribute=value] SelectorThe selector selects every element with both the specified attribute and specified value.
- jQuery – [attribute!=value] SelectorThe selector selects every element with the specific attribute that does NOT have the specified value.
- jQuery – [attribute$=value] SelectorThe selector selects every element with a specific attribute that has a value ending in a specified string.
- jQuery – [attribute|=value] SelectorThe selector selects every element with a specific attribute that has a value equal to or starting with a specified value.
- jQuery – [attribute^=value] SelectorThe selector selects every element with a specific attribute that starts with a value beginning with a specified string.
- jQuery – [attribute~=value] SelectorThe selector selects every element with a specific attribute that has a value containing a specified stand-alone word.
- jQuery – [attribute*=value] SelectorThe selector selects every element with a specific attribute that has a value containing a specified string even as part of another word.
- jQuery – :button SelectorThe :button selector selects HTML form input elements and button elements with type=”button”.
- jQuery – :checkbox SelectorThe :checkbox selector selects HTML form input elements with type=”checkbox”.
- jQuery – :checked SelectorThe :checked selector selects all checked HTML checkboxes or radio buttons.
- jQuery – .class SelectorThe .class selector selects all HTML elements with a specific class, which may include multiple elements on the page.
- jQuery – :contains() SelectorThe :contains() selector selects elements containing a specified string directly within it or indirectly in a child, grandchild, etc. of the element.
- jQuery – :disabled SelectorThe :disabled selector selects all HTML form elements that are disabled.
- jQuery – Element SelectorThe element selector selects all HTML elements with a specific element tag name.
- jQuery – Element + Next SelectorThe element + next selector selects the very next element specified after (not within) the first specified element.
- jQuery – Element ~ Siblings SelectorThe element ~ siblings selector selects sibling elements that appear after the specified element. Both of the specified elements must share the same parent.
- jQuery – :empty SelectorThe :empty selector selects empty HTML elements, which means an element without any child elements or text.
- jQuery – :enabled SelectorThe :enabled selector selects all HTML form elements that are enabled.
- jQuery – :even SelectorThe :even selector selects every element with an even index number (0, 2, 4, etc.). This is often used to create a striped row look in HTML tables.
- jQuery – :file SelectorThe :file selector selects HTML form input elements with type=”file”.
- jQuery – :first-child SelectorThe :first-child selector selects all HTML elements of a specified type that are also the first child of their parent element.
- jQuery – :first-of-type SelectorThe :first-of-type selector selects all elements that are the first child of a specified type of their parent element.
- jQuery – :focus SelectorThe :focus selector selects the element that currently has focus.
- jQuery – :has() SelectorThe :has() selector selects all elements that have one or more elements inside of them that matches the specified selector.
- jQuery – :header SelectorThe :header selector selects all header elements – h1, h2, h3, h4, h5, and h6.
- jQuery – :hidden SelectorThe :hidden selector selects hidden elements (display: none, form elements with type=hidden, elements with zero width/height, child with a hidden parent).
- jQuery – #id SelectorThe #id selector selects an HTML element with a specific id. HTML only allows for one unique #id per document.
- jQuery – :image SelectorThe :image selector selects HTML form input elements with type=”image”.
- jQuery – :input SelectorThe :input selector selects HTML form elements and button elements.
- jQuery – :lang() SelectorThe :lang() selector selects all elements with the language attribute starting with a specified value (e.g., lang=”en” or lang=”en-us”).
- jQuery – :last-child SelectorThe :last-child selector selects all HTML elements of a specified type that are also the last child of their parent element.
- jQuery – :last-of-type SelectorThe :last-of-type selector selects all elements that are the last child of a specified type of their parent element.
- jQuery – :nth-child() SelectorThe :nth-child() selector selects all specified elements that are the nth child of their parent, regardless of all the children’s types.
- jQuery – :not() SelectorThe :not() selector selects all elements except the specified element.
- jQuery – :nth-last-child() SelectorThe :nth-last-child() selector selects all elements that are the nth child of their parent, regardless of all the children’s types, counting from the end.
- jQuery – :nth-last-of-type() SelectorThe :nth-last-of-type() selector selects all elements that are the nth child of a specified type of their parent, counting from the last child.
- jQuery – :nth-of-type() SelectorThe :nth-of-type() selector selects all elements that are the nth child of a specified type of their parent.
- jQuery – :odd SelectorThe :odd selector selects every element with an odd index number (1, 3, 5, etc.). This is often used to create a striped row look in HTML tables.
- jQuery – :only-child SelectorThe :only-child selector selects every element that is the only child of its parent. If the parent has multiple child elements, it will NOT be selected.
- jQuery – :only-of-type SelectorThe :only-of-type selector selects every element that is the only child of its type of its parent.
- jQuery – Parent Descendant SelectorThe Parent Descendant selector selects all elements that are descendants (child, grandchild, great-grandchild, etc) of a specified element.
- jQuery – :parent SelectorThe :parent selector selects all specified html elements that have child elements or text.
- jQuery – Parent > Child SelectorThe Parent > Child selector selects all elements that are a direct child of the specified element.
- jQuery – :password SelectorThe :password selector selects HTML form input elements with type=”password”.
- jQuery – :radio SelectorThe :radio selector selects HTML form input elements with type=”radio”.
- jQuery – :reset SelectorThe :reset selector selects HTML form input elements and button elements with type=”reset”.
- jQuery – :root SelectorThe :root selector selects the document’s root element which is the html tag.
- jQuery – :submit SelectorThe :submit selector selects HTML form input elements and button elements with type=”submit”.
- jQuery – :selected SelectorThe :selected selector selects option elements from a dropdown list that are preselected.
- jQuery – :text SelectorThe :text selector selects HTML form input elements with type=”text”.
- jQuery – :visible SelectorThe :visible selector selects elements NOT set to: display: none, form elements with type=hidden, elements with zero width/height, child with a hidden parent.
jQuery Notes:
- To use jQuery on your site, it must first be downloaded from the official jQuery site and linked to in your document <head>, or linked to via a CDN in your document <head>
- It is generally good practice to place your jQuery code/function inside the document load function so that the action takes place ONLY after the document has finished loading
- When using jQuery, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.