jQuery选择器 大于 空格 波浪线 加号

本文详细解释了JQuery中四种不同的选择器符号:空格、大于号、加号及波浪号的使用方法及其含义。空格表示获取所有子孙节点;大于号用于选择直接子节点;加号获取紧邻的兄弟节点;波浪号则获取所有后续兄弟节点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

JQuery选择器 大于 空格 波浪线 加号的区别

元素遍历

符号说明
空格$(‘parent child’)表示获取parent下的所有的child节点(所有的子孙)。
大于号$(‘parent > child’)表示获取parent下的所有叫child的儿子(第一代)。
加号$(‘pre + nextbrother’)表示获得pre节点的下一个兄弟节点,相当于next()方法
波浪号$(‘pre ~ brother’)表示获取pre节点的后面的所有兄弟节点,相当于nextAll()方法。

参见 Jquery API


Child Selector (“parent > child”)

Selects all direct child elements specified by “child” of elements specified by “parent”.


Descendant Selector (“ancestor descendant”)

Selects all elements that are descendants of a given ancestor.


Next Adjacent Selector (“prev + next”)

Selects all next elements matching “next” that are immediately preceded by a sibling “prev”.


Next Siblings Selector (“prev ~ siblings”)

Selects all sibling elements that follow after the “prev” element, have the same parent, and match the filtering “siblings” selector.


Attribute Contains Prefix Selector [name|=”value”]

Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-).


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值