jQuery的选择对象

Selector

Example

Description

Element

$("td")

Select an HTML element tag

#id

$("#divMessage")

Selects an element by its id

.cssclass

$(".gridalternate")

Selects a CSS style

selector,selector

$("input:button,input:text")

Multiple comma separated selectors can be combined into a single selection.

ancestor descendant

$("#divMessage a")

A space between selectors/elements/tags finds nested elements. This syntax is similar to Css ancestor descendant syntax.

parent > child

> child

$("p > b")

Matches all immediate children of an element or selector expression that match the right element/selector.

prev ~ siblings

~ siblings

$("#row_11:nth-child(2)~td")

$("~td")

Matches the next siblings at the sample level as the preceeding expression. Example, matches 3-nth columns of a table row. Best used as a find() or filter() against an existing jQuery instance.

prev + nextsibling

+ nextsibling

$("#tdMoneyCol+td")

$("+td")

Matches the following sibling. Works best with find() or filter() against an existing jQuery object.

:filter

$("input:button")

: applies filters to the query. jQuery support CSS 3 filters plus a number of custom filters.

Examples: :not,:button,:visible,:hidden,:checked,:first,nth-child(1),:has,:is,:contains,:parent

[@attribute]

$("p[class=gridalternate]

Selects an attribute of an element

= equals string

^= startswith

$= endswith

*= contains

 

源文档 <http://www.west-wind.com/presentations/jQuery/default.aspx>

 

posted @ 2008-10-11 15:11  _龙猫  阅读(372)  评论(0)    收藏  举报