Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含几个列表项的列表,它们都是隐藏的:
<ul> <li rel=""> </li> ... </ul>
我想显示属性rel只是一个空字符串的列表项。
rel
有谁知道我该怎么做?
您可以使用 CSS 和属性选择器来做到这一点:
ul li[rel=""] { display: list-item; }
或者使用 jQuery:
$('ul li[rel=""]').show();
首先使用data-属性或找出不使用属性的方法。
data-
尝试像这样使用
$('ul li').hide(); $('ul li[rel=""]').show();
演示在这里
在jQuery中
$("li[rel!='']").show();