What does the $ symbol in 1.jQuery do?
$ as an alias for jquery, such as $ (document). Ready () is jquery (document)
What kinds of 2.jQuery selectors are there?
Basic selector: $ ("#id")-〉 get element by ID
$ (". Class")-〉 gets the element through the given class name
$ ("P")-〉 get element by name match
$ ("span, #id,..."). CSS ()-〉 multiple selection merge return
Hierarchy selector: $ ("div span") all spans in-〉div
$ ("div > span")-〉div sub-element span
$ (". Red + div")-〉 Select the next div sibling element with class red
$ (". Red ~ div")-〉 Select all div sibling elements behind the element of class red
Filter Selector: The basic filter Selector {$ ("Div:first")-〉 the first Div; $ ("Div:last")-〉 the last div; $ ("Input:not (. Red)")-〉 Select the input element that is not red;
$ ("Input:even")-〉index is an even INPUT element; $ ("input:odd")-〉index is an odd input element; $ ("Input:eq (1)"), $ ("INPUT:GT (1)"),
$ ("Input:lt (1)") is based on index (equal, greater than, less than) to select the element; $ (": Header")-〉 Select all H1 H2 H3 ...;
$ (": Focus")-〉 gets the element that is currently focusable}
The Content filter Selector {$ ("div:contains (' ab ')")-〉 selects a DIV element containing the text "AB", and $ ("Div:empty")-〉 selects a div empty element that does not contain child elements;
$ ("Div:has (P)")-〉 Select the div element that contains the P element; $ ("div:parent")-〉 Select the DIV element that owns the child element}
Visibility Filter Selector {$ ("Input:hidden")-〉 selects all hidden input elements; $ ("div:visible")-〉 selects all visible div elements}
The attribute filter Selector {$ ("div[title= ' Test ']")-〉 Select the div element with title equal to "Test", and $ ("Div[id]")-〉 Select the element that owns the attribute ID;
$ ("div[id= ' id1 '][title= ' test1 ']")-〉 multi-conditional compound selection}
Form object property filtering {e.g.: selected; enabled;:d isabled;: checked;}
The onload () function in 3.body and $ (document) in jquery. What is the difference between ready ()?
The onload () function is called only once when all of the page's resources have been loaded and can only be used once; Ready () is called after the page has finished loading the DOM and can be used multiple times.
4. Set the border of all elements of the page to a 2px wide dashed line?
$ ("*"). CSS ("Border", "2px dashed red"); Solid is a solid line; Dashed as dashed
What is the function of the delegate () function in 5.jQuery?
If you have a parent element, you need to add time to the child element under it, you can use Delegate (), the code is as follows:
$ ("U1"). Delegate ("Li", "click", Function () {
$ (this). Hide ();
});
6. Use jquery to disable the browser's forward back button?
$ (document). Ready (function () {
Window.history.forward (1); or Window.history.forward (-1);
});
What is the difference between a 7.jQuery selector and a CSS selector?
The jquery selector supports CSS selectors, adds styles and behaviors to objects, and CSS selectors can only add styles.
8.jQuery achieve table interlaced color?
The HTML code is as follows:
<table>
<tbody>
<TR class= "Parent" id= "row_01" ></tr>
<tr class= "child_row_01" ></tr>
<tr class= "child_row_01" ></tr>
<TR class= "Parent" id= "row_02" ></tr>
...
</tbody>
$ (function () {
$ ("Tr.parent"). Click (function () {
$ (This)
. Toggleclass ("selected")//delete or add highlighting
. Siblings ("Child" +this.id). Toggle (); Hide or show child rows
});
});
CSS style controls interlaced discoloration:
. line{
table{
tbody{
Tr:nth-child (odd) {background:red;}
Tr:nth-child (even) {background:blue;}
}
}
}
jquery Related knowledge