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

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

问题描述

我试图找到元素ID包含特定文本的页面上的所有元素。然后我需要根据它们是否隐藏来过滤找到的元素。

解决方案

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

注意选择符开头的星号'*'匹配所有元素



请参阅属性包含选择器,以及:可见:hidden 选择器。 p>

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天全站免登陆