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

查看:13
本文介绍了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();

这将隐藏所有具有 style 属性的元素.但是如果我想隐藏那些 without 它,我的选择器应该是什么样子?

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