jQuery element ~ siblingsSelector

jQuery 选择器jQuery Selector

Examples

Select all <p> elements that are siblings of <div> elements:

$("div ~ p")

Try it Yourself »

Definition and Usage

The ("element ~ siblings") selector selects all elements that are siblings of the specified element "element".

For example:

  • $("div ~ p")- Select all <p> elements that are siblings of <div> elements.

Note:The two specified elements share the same parent element.


Syntax

("element ~ siblings")

Parameter Description
element Required. Any valid jQuery selector.
siblings Required. Specifieselementthe siblings of the parameter.


jQuery 选择器jQuery Selector

Other Extensions