2013-10-14 02:36:58 +00:00
|
|
|
---
|
2012-03-16 06:14:31 +00:00
|
|
|
title: jQuery
|
2015-11-24 05:02:17 +00:00
|
|
|
category: JavaScript libraries
|
2017-08-29 22:28:48 +00:00
|
|
|
tags: [WIP]
|
|
|
|
weight: -1
|
2012-03-16 06:14:31 +00:00
|
|
|
---
|
|
|
|
|
2014-06-26 08:43:36 +00:00
|
|
|
### Traversing
|
|
|
|
|
2017-08-29 22:28:48 +00:00
|
|
|
```js
|
|
|
|
$('.box')
|
|
|
|
.children()
|
|
|
|
.closest('div')
|
|
|
|
.filter(':selected')
|
|
|
|
.find('div')
|
|
|
|
.has('div')
|
|
|
|
.first()
|
|
|
|
.next('div')
|
|
|
|
.nextUntil('div')
|
|
|
|
```
|
2014-06-26 08:43:36 +00:00
|
|
|
|
2017-08-29 22:28:48 +00:00
|
|
|
## Advanced features
|
2014-06-26 08:43:36 +00:00
|
|
|
|
2012-03-16 06:14:31 +00:00
|
|
|
### Extending selectors
|
|
|
|
|
2017-08-29 22:28:48 +00:00
|
|
|
```js
|
|
|
|
$.expr[':'].inline = function (el) {
|
|
|
|
return $(el).css('display') === 'inline'
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Enables `$(':inline')`
|
2012-03-16 06:14:31 +00:00
|
|
|
|
|
|
|
### Extend CSS properties
|
|
|
|
|
2017-08-29 22:28:48 +00:00
|
|
|
```js
|
|
|
|
$.cssHooks.someCSSProp = {
|
|
|
|
get: function (elem, computed, extra) {
|
|
|
|
},
|
|
|
|
set: function (elem, value) {
|
|
|
|
}
|
|
|
|
}
|
2012-03-16 06:14:31 +00:00
|
|
|
|
2017-08-29 22:28:48 +00:00
|
|
|
// Disable "px"
|
|
|
|
$.cssNumber["someCSSProp"] = true
|
|
|
|
```
|
2012-03-16 06:14:31 +00:00
|
|
|
|
|
|
|
### fn.animate() hooks
|
|
|
|
|
2017-08-29 22:28:48 +00:00
|
|
|
```js
|
|
|
|
$.fn.step.someWhatever = function(fx) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
```
|