使用jQuery查找元素ID包含特定文本的页面上的所有元素 [英] Find all elements on a page whose element ID contains a certain text using jQuery
本文介绍了使用jQuery查找元素ID包含特定文本的页面上的所有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在元素 ID 包含特定文本的页面上查找所有元素.然后我需要根据它们是否隐藏来过滤找到的元素.非常感谢任何帮助.
解决方案
$('*[id*=mytext]:visible').each(function() {$(this).doStuff();});
注意选择器开头的星号*"匹配所有元素.>
请参阅属性包含选择器,以及: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屋!
查看全文