jQuery 1.6 API 中文版

Selectors

Basics

#id
element
.class, .class.class
*
selector1, selector2

Hierarchy

ancestor descendant
parent > child
prev + next
prev ~ siblings

Basic Filters

:first
:last
:not(selector)
:even
:odd
:eq(index)
:gt(index)
:lt(index)
:header
:animated
:focus1.6+

Content Filters

:contains(text)
:empty
:has(selector)
:parent

Visibility Filters

:hidden
:visible

Child Filters

:nth-child(expr)
:first-child
:last-child
:only-child

Attribute Filters

[attribute]
[attribute=value]
[attribute!=value]
[attribute^=value]
[attribute$=value]
[attribute*=value]
[attribute|=value]
[attribute~=value]
[attribute][attribute2]

Forms

:input
:text
:password
:radio
:checkbox
:submit
:image
:reset
:button
:file

Form Filters

:enabled
:disabled
:checked
:selected

Core

jQuery function

$.jQuery( selector [, context] ), .jQuery( element ), .jQuery( elementArray ), .jQuery( jQueryObject ), .jQuery( )
$.jQuery( html [, ownerDocument] ), .jQuery( html, props )
$.jQuery( fn )
def.when(deferreds)
fnjQuery.sub( )
$.holdReady( hold )

jQuery Object Accessors

$.each( fn(index, element) )
num.size( ) , .length
str.selector
el.context
$.eq( index )
jQuery.error( str )
[el],el.get( [index] )
num.index( )indexindex( selector )indexindex( element )
$jQuery.pushStack( elements, [name, arguments] )
arr.toArray( )

Interoperability

$jQuery.noConflict( [extreme] )

Attributes

Attributes

str.attr( name ) | (name , value ) )1.6*
$.attr( name, val ), .attr( map ), .attr( name, fn(index, attr) )
$.removeAttr( name )
$.prop( name )1.6+
$.removeProp( name )1.6+

Class

$.addClass( class ), .addClass( fn(index, class) )
bool.hasClass( class )
$.removeClass( [class] ), .removeClass( fn(index, class) )
$.toggleClass( class [, switch] ), .toggleClass( fn(index, class) [, switch] )

HTML, text

str.html( )
$.html( val ), .html( fn(index, html) )
str.text( )
$.text( val ), .text( fn(index, html) )

Value

str,arr.val( )
$.val( val ), .val( fn() )

CSS

CSS

str.css( name )
$.css( name, val ), .css( map ), .css( name, fn(index, val) )

Positioning

obj.offset( )
$.offset( coord ), .offset( fn( index, coord ) )
$.offsetParent( )
obj.position( )
int.scrollTop( )
$.scrollTop( val )
int.scrollLeft( )
$.scrollLeft( val )

Height and Width

int.height( )
$.height( val ), .height( fn(index, height ) )
int.width( )
$.width( val ), .width(( fn(index, height ) )
int.innerHeight( )
int.innerWidth( )
int.outerHeight( [margin] )
int.outerWidth( [margin] )

Deferred

deferred object = {
defdone(doneCallbacks)
deffail(failCallbacks)
boolisRejected()
boolisResolved()
defreject([args])
defrejectWith(context, [args])
defresolve([args])
defresolveWith(context, [args])
defthen(doneCallbacks, failCallbacks)
}
def.promise(deferreds)1.6+
def.pipe(deferreds)1.6+
def.always(deferreds)1.6+

Traversing

Filtering

$.eq( index )
$.first( )
$.last( )
$.has( selector ), .has( element )
$.filter( selector ), .filter( fn(index) )
bool.is( selector | function(index) | jQuery object | element )1.6*
$.map( fn(index, element) )
$.not( selector ), .not( elements ), .not( fn( index ) )
$.slice( start [, end] )

Tree traversal

$.children( [selector] )
$.closest( selector [, context] | jQuery object | element )1.6*
arr.closest( selectors [, context] )
$.find( selector | jQuery object | element )1.6*
$.next( [selector] )
$.nextAll( [selector] )
$.nextUntil( [selector] )
$.offsetParent( )
$.parent( [selector] )
$.parents( [selector] )
$.parentsUntil( [selector] )
$.prev( [selector] )
$.prevAll( [selector] )
$.prevUntil( [selector] )
$.siblings( [selector] )

Miscellaneous

$.add( selector [, context] ), .add( elements ), .add( html )
$.andSelf( )
$.contents( )
$.end( )

Manipulation

Inserting Inside

$.append( content ), .append( fn( index, html ) )
$.appendTo( target )
$.prepend( content ), .prepend( fn( index, html ) )
$.prependTo( target )

Inserting Outside

$.after( content ), .after( fn() )
$.before( content ), .before( fn() )
$.insertAfter( target )
$.insertBefore( target )

Inserting Around

$.unwrap( )
$.wrap( wrappingElement ), .wrap( fn )
$.wrapAll(wrappingElement ), .wrapAll( fn )
$.wrapInner( wrappingElement ), .wrapInner( fn )

Replacing

$.replaceWith( content ), .replaceWith( fn )
$.replaceAll( selector )

Removing

$.detach( [selector] )
$.empty( )
$.remove( [selector] )

Copying

$.clone( [withDataAndEvents], [deepWithDataAndEvents] )

Events

Page Load

$.ready( fn() )

Event Handling

$.bind( type [, data ], fn(eventObj) )
$.bind( type [, data], false )
$.bind( array )
$.unbind( [type] [, fn])
$.one( type [, data ], fn(eventObj) )
$.trigger( event [, data])
obj.triggerHandler( event [, data])
$.delegate( selector, type, [data], handler)
$.undelegate( [selector, type, [handler]]) | ( selector, events ) | ( namespace ) 1.6*

Live Events

$.live( eventType [, data], fn() )
$.die( ), .die( [eventType] [, fn() ])

Interaction Helpers

$.hover( fnIn(eventObj), fnOut(eventObj))
$.toggle( fn(eventObj), fn2(eventObj) [, ...])

Event Helpers

function ( [data,] [fn] )

Event object

event = {
elcurrentTarget,
*data,
boolisDefaultPrevented(),
boolisImmediatePropagationStopped(),
boolisPropagationStopped(),
strnamespace,
numpageX,
numpageY,
preventDefault(),
elrelatedTarget,
objresult,
stopImmediatePropagation(),
stopPropagation(),
eltarget,
numtimeStamp,
strtype,
strwhich
}

Effects

Basics

$.show( [ duration [, easing] [, fn] ]  )
$.hide( [ duration [, easing] [, fn] ]  )
$.toggle( [showOrHide] )
$.toggle( duration [, easing] [, fn] )

Sliding

$.slideDown( duration [, easing] [, fn] )
$.slideUp( duration [, easing] [, fn] )
$.slideToggle( [duration] [, easing] [, fn] )

Fading

$.fadeIn( duration [, easing] [, fn] )
$.fadeOut( duration [, easing] [, fn] )
$.fadeTo( [duration,] opacity [, easing] [, fn] )
$.fadeToggle( [duration,] [, easing] [, fn] )

Custom

$.animate( params [, duration] [, easing] [, fn] )
$.animate( params, options )
$.stop( [clearQueue] [, jumpToEnd] )
$.delay( duration [, queueName] )

Settings

booljQuery.fx.off
numjQuery.fx.interval

AJAX

Low-Level Interface

jqXHRjQuery.ajax( options, [settings] )
  • mapaccepts
  • boolasync = true
  • fnbeforeSend( jqXHR, config)
  • boolcache = true
  • fncomplete( jqXHR, status)
  • mapcontents
  • strcontentType
  • objcontext
  • mapconverters
  • boolcrossDomain
  • obj, strdata
  • fndataFilter( data, type )
  • boolglobal = true
  • mapheaders
  • boolifModified = false
  • strjsonp
  • fnjsonpCallback
  • strpassword
  • boolprocessData = true
  • strscriptCharset
  • mapstatusCode
  • numtimeout
  • booltraditional
  • strtype = 'GET'
  • strurl = curr. page
  • strusername
  • fnxhr
  • strdataType ∈ {xml, json, script, html}
  • fnerror( jqXHR, status, errorThrown )
  • fnsuccess( data, status, jqXHR )
jQuery.ajaxSetup( options )

Shorthand Methods

$.load( url [, data] [, fn( responseText, status, XHR )] )
jqXHRjQuery.get( url [, data] [, fn( data, status, XHR )] [, type] )
jqXHRjQuery.getJSON( url [, data] [, fn( data, status )] )
jqXHRjQuery.getScript( url [, fn( data, status )] )
jqXHRjQuery.post( url [, data] [, fn( data, status )] [, type] )

Global Ajax Event Handlers

$.ajaxComplete( fn( event, XHR, options ) )
$.ajaxError( fn( event, XHR, options, thrownError ) )
$.ajaxSend( fn( event, XHR, options ) )
$.ajaxStart( fn(  ) )
$.ajaxStop( fn(  ) )
$.ajaxSuccess( fn(event, XHR, options) )

Miscellaneous

str.serialize(  )
[obj].serializeArray(  )
strjQuery.param( obj, [traditional] )

Utilities

Browser and Feature Detection

objjQuery.support
objjQuery.browserdeprecated
strjQuery.browser.versiondeprecated
booljQuery.boxModeldeprecated

Basic operations

objjQuery.each( obj, fn( index, valueOfElement ) )
objjQuery.extend( [deep,] target, obj1 [, objN] )
arrjQuery.grep( array, fn( element, index ) [, invert] )
arrjQuery.makeArray( obj )
arrjQuery.map( arrayOrObject, fn( element, index ) )1.6*
numjQuery.inArray( val, array )
arrjQuery.merge( first, second )
fnjQuery.noop
fnjQuery.proxy( fn, scope ), jQuery.proxy( scope, name )
arrjQuery.unique( array )
strjQuery.trim( str )
objjQuery.parseJSON( str )

Data functions

$.clearQueue( [name] )
$.dequeue( [name] ), jQuery.dequeue( [name] )
objjQuery.data( element, key ), jQuery.data(  )
obj.data(  ), .data( key )
$.data( key, val ), .data( obj )
$.removeData( [name] )
[fn].queue( [name] ) jQuery.queue( [name] )
$.queue( [name,] fn( next ) ), jQuery.queue( [name,] fn(  ) )
$.queue( [name,] queue ), jQuery.queue( [name,] queue )

Test operations

strjQuery.type( obj )
booljQuery.isArray( obj )
booljQuery.isEmptyObject( obj )
booljQuery.isFunction( obj )
booljQuery.isPlainObject( obj )
booljQuery.isWindow( obj )

下载jQuery 1.6 API 中文版

反馈和联系

腾讯微薄:@julying

Email:i[a]julying.com

主页 http://julying.com

本作品由 愚人码头 翻译,由 脚本之家 整理、修订