使用jQuery查找页面上元素ID包含特定文本的所有元素 [英] Find all elements on a page whose element ID contains a certain text using jQuery

查看:22
本文介绍了使用jQuery查找页面上元素ID包含特定文本的所有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找页面上元素 ID 包含特定文本的所有元素.然后,我需要根据它们是否隐藏来过滤找到的元素.非常感谢任何帮助.

解决方案

$('*[id*=mytext]:visible').each(function() {$(this).doStuff();});

注意选择器开头的星号*"匹配所有元素.p>

请参阅 属性包含选择器,以及 :visible:隐藏的选择器.

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.

解决方案

$('*[id*=mytext]:visible').each(function() {
    $(this).doStuff();
});

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.

这篇关于使用jQuery查找页面上元素ID包含特定文本的所有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆