1.$ ("#tt") gets always a jquery object, so to determine if there is an object on the page cannot be like JS
if($ ("#tt")) {}
View Code
But by:
if ($ ("#tt"0) {}
View Code
PS: When there is no element in the page ID TT, jquery will not error, and JS will error
2. jquery Layer Selector $ ("ancestor descendant") and $ ("Parent>child")
is is <em>really <strong>very</strong></em> important.</div>
View Code
Like a family three generations together, Grandpa, Father and you, so grandpa's son element is your father, while your father is also the descendants of Grandpa elements, and you are only the descendants of Grandpa elements.
Summary: Descendant elements include child elements, which refer to the father's first generation.
3. Types of jquery Selectors
3.1 Basic Selector
3.2 Hierarchy Selector
3.3 Filter Selector
3.3.1 Basic Filter Selector
$ ("Div:first") Select the first div;$ ("Div:last") Select the Last div;$ ("Input:not (. MyClass)") Select the MyClass ("input;$") of the class that is not Input:even Select an even-numbered index
Input; $ ("input:odd") Select input;$ with an odd index ("Input:eq (1)") to select an INPUT element with an index equal to 1, and $ ("INPUT:GT (1)") to select an index greater than 1input;$ ("input:lt (1)"
Select input with index less than 1
3.4 form Selector
Sharp jquery Learning Notes