Sharp jquery-Selector and sharp jquery-Selector
1 jquery $ (document ). ready (function () {}) can be abbreviated to $ (function () {}) 2 jquery object and DOM object. ① jquery object and DOM object cannot use method 1 of the other Party: convert a jquery object to a DOM object. ① A jquery object is a collection of DOM objects. You can use the subscript [index] to obtain DOM objects in the jquery object. ② you can use the method provided by jquery, $ ('# obj '). get (index) to get the DOM object. 2. Convert the DOM object to a jquery object. ① wrap the DOM object with $ (DOM object). 3. conflict with other libraries) the jquery library is imported after other libraries. ① you can use jQuery. noConflict () method hand over $ control to other libraries (such as prototype. js). You can use jquery () as the manufacturing factory. ② you can also customize the backup name: var $ j = jquery. noConflict () custom shortcuts ③ if you want to use $, other libraries also use $; a jquery. noConflict () // transfer $ symbolic control in the outer layer; jquery (function ($) {continue to use the $ () method;}) B jquery. noconflict (); (function ($) {pass $ as the form parameter to the anonymous function}) (jquery); jquery can be directly used for importing data to other libraries without using jquery. noconflict () method; 4 jqueryDOM operation ① jquery gets objects forever; if it is used to determine whether an element exists, it cannot use if ($ ("# tt ")) {} and determine the length of the obtained object if ($ ("# tt "). length> 0) {} 5 note that the jquery selector contains special characters ① a selector containing special characters must use a conversion symbol \ eg: $ ("# id \ # B ") when you get an element with id [1] $ ("# id \ [1 \]") 6 jquery selector with spaces ① var $ t_a = $ ('. test: Den den '); // contains spaces. The descendant selector indicates the hidden element ② var $ t_ B = $ ('. test: Den den '); // It does not contain spaces. The filter selector indicates that the hidden class is the test element. ps (: contains ('') the selector detects the content in the filter element and is selected as long as the matching content is contained. As long as I have it, as long as I want it; the selected element still complies with the rule of space.) 7: last: last-child ①: last get the last element in the matching set ②: last-child if only one parent element in the matching set is the same as last; if it is a set of child elements of several parent elements, the child element selected by last-child is the last element set of the parent element.