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

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 (-).


posted @   一杯半盏  阅读(204)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示