本文介紹了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 選擇器 - 查找沒有指定屬性的對象的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!