OSDN Git Service

Regular updates
[twpd/master.git] / jquery.md
1 ---
2 title: jQuery
3 category: JavaScript libraries
4 layout: 2017/sheet
5 tags: [WIP]
6 weight: -1
7 ---
8
9 ### Traversing
10
11 ```js
12 $('.box')
13   .children()
14   .closest('div')
15   .filter(':selected')
16   .find('div')
17   .has('div')
18   .first()
19   .next('div')
20   .nextUntil('div')
21 ```
22
23 ## Advanced features
24
25 ### Extending selectors
26
27 ```js
28 $.expr[':'].inline = function (el) {
29   return $(el).css('display') === 'inline'
30 }
31 ```
32
33 Enables `$(':inline')`
34
35 ### Extend CSS properties
36
37 ```js
38 $.cssHooks.someCSSProp = {
39   get: function (elem, computed, extra) {
40   },
41   set: function (elem, value) {
42   }
43 }
44
45 // Disable "px"
46 $.cssNumber["someCSSProp"] = true
47 ```
48
49 ### fn.animate() hooks
50
51 ```js
52 $.fn.step.someWhatever = function(fx) {
53   // ...
54 }
55 ```