用户登录
用户注册

分享至

jQuery 选择器 - 查找没有指定属性的对象

  • 作者: 妖邪y
  • 来源: 51数据库
  • 2022-10-20

问题描述

我在一个页面上有几个对象,我想只在其中一些对象上使用 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();
软件
前端设计
程序设计
Java相关