jQuery选择器 - 查找没有指定属性的对象 [英] jQuery selectors - find objects without specified attribute

查看:706
本文介绍了jQuery选择器 - 查找没有指定属性的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面上的几个对象,我想使用jQuery只对其中一些 - 没有指定的属性的那些执行操作。所以:

I have several objects on a page and I want to perform an operation using jQuery only on some of them - the ones that don't have a specified attribute. So:

<li style='...'>some text</li>
<li style='...'>some other text</li>
<li>some very diffrent text</li>

在javascript中我会有:

and in javascript I would have:

$('li[style]').hide();

将隐藏所有带有风格的元素 sttribute。但如果我想隐藏而不它,我的选择器应该怎么样?

that would hide all elements with a style sttribute. But if I want to hide the ones without it, how should my selector look like?

推荐答案

jQuery("li:not([style])").hide();

这篇关于jQuery选择器 - 查找没有指定属性的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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