- First, the basic filter selector (key to master the following eight)
: First select $ ("Div:first"). CSS ("Color", "red");
: Last selects the final element $ ("Div:last"). CSS ("Color", "red");
: Not remove the element specified outside the selector $ ("Div:not"). CSS ("Color", "red");
: Even the selected index number is an even-numbered element $ ("Div:even"). CSS ("Color", "red");
: Odd the selected index number is an odd element of $ (' div:odd '). CSS ("Color", "red");
: EQ (index) selects the index element $ (' Div:eq (5) '). CSS ("Color", "red");
: GT (Index) Select the element with index number greater than Index $ (' DIV:GT (8) '). CSS ("Color", "red");
: LT (index) Select the element with index number less than index (' div:lt (3) '). CSS ("Color", "red");
Second, Attribute filter selector (six must remember)
(1): [attribute] Select the element that owns this property $ (' Div:[attribute] '). CSS (' background-color ', ' red ');
(2): [Attribute=value] Select the element with attribute value = value $ (' div:[attribute=text] ')
(3): [Attribute!=value] Select the element with attribute value not as Value $ (' div:[attribute!=text] ')
(4): [Attribute^=value] Select an element with value starting with value $ (' div:[attribute^=text] ')
(5): [Attribute$=value] Select the element that ends with value for the attribute $ (' div:[attribute$=text] ')
(6): [Attribute*=value] Select the attribute value contains the element of value $ (' div:[attribute*=text] ')
Iii. Content Filter Selector (four must be remembered)
: Contains select the element that contains text for $ (' Div:contains (. Mini) '). CSS ("Color", "red");
: Has (ID selector name, class selector name) Select the element that contains the selector that matches the $ (' Div:has (. Mini) '). CSS ("Color", "red");
: Empty selects elements that do not contain child elements $ (' Div:empty '). CSS ("Color", "red");
:p arent Select the element containing the child element $ (' div:parent '). CSS ("Color", "red");
Iv. Sub-element filter selector (remember eight)
(1): Nth-child (Index) Select the index, even, or odd elements under each parent node.
$ (' Div.one:nth-child (8) '). CSS (' Background-color ', ' #900 ');
(2): First-child Select the first child element under each parent element $ (' Div.one:first-child (8) '). CSS (' Color ', ' red ');
(3): Last-child Select the last child element under each parent element $ (' Div.one:last-child (8) '). CSS (' Color ', ' red ');
(4): Only-child Select only one child element of the element $ (' Div.one:only-child (8) '). CSS (' Color ', ' red ');
(5): Enabled Select all available elements $ (' #form1 input:enabled '). Val ("vaotoo.com");
(6):d isabled Select all the unavailable elements $ (' #form1 input:disabled '). Val ("vaotoo.com");
(7): checked selects all selected elements (typically (in HTML) RadioButton, checkbox tags);
$ (' input:checked '). Text ("vaotoo.com");
(8): Selected Select the selected option Element (Option=select in the Select drop-down list tag)
$ (' select:selected '). each (function () {
str + = $ (this). Text () + ",";
});
V. Visibility Filter selector (two)
: Hidden
: Visibal
jquery Filter Selector, select first few elements, after several elements, content filter selector, etc.