No matter which type of selector we want to use in jQuery – be it CSS, XPath, or custom – we always start with the dollar sign and parentheses: $()
$() Factory Function
Let’s see some more common examples:
A tag name: $(‘p’) gets all paragraphs in the document.
An ID: $(‘#some-id’) gets the single element in the document that has the corresponding some-id ID.
A class: $(‘.some-class’) gets all elements in the document that have a class of some-class.
Find each liste item (li) that is a child (>) of an element with an ID of selected-id (#selected-id).
Find each list item that do not have a class of horizontal, which is a child of #selected-id.