使用 jQuery 查找页面上元素 ID 包含特定文本的所有元素
我正在尝试查找页面上元素 ID 包含特定文本的所有元素。 然后,我需要根据找到的元素是否隐藏来过滤它们。 任何帮助是极大的赞赏。
I'm trying to find all elements on a page whose element ID contains a certain text. I'll then need to filter the found elements based on whether they are hidden or not. Any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请注意选择器开头的星号“*”匹配所有元素。
请参阅属性包含选择器,以及:visible 和 :隐藏选择器。
Note the asterisk '*' at the beginning of the selector matches all elements.
See the Attribute Contains Selectors, as well as the :visible and :hidden selectors.
如果您通过包含查找,那么它会像这样
如果您通过开头为查找,那么它会像这样
如果您通过<查找 如果你想选择 name 包含给
如果你想选择 id 不是给定字符串的元素
定单词的元素,以空格分隔
如果要选择 id 等于给定字符串或以该字符串开头后跟连字符的元素
If you're finding by Contains then it'll be like this
If you're finding by Starts With then it'll be like this
If you're finding by Ends With then it'll be like this
If you want to select elements which id is not a given string
If you want to select elements which name contains a given word, delimited by spaces
If you want to select elements which id is equal to a given string or starting with that string followed by a hyphen
这将选择 ID 包含“foo”并且可见的所有 DIV
This selects all DIVs with an ID containing 'foo' and that are visible
感谢你们俩。 这对我来说非常有效。
Thanks to both of you. This worked perfectly for me.