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.
我需要能够检查是否有一个带有 class='active' 和自定义属性 data-popup='true' 的 div - 例如:下面的第二个。
如何检查具有这两个特征的 div 是否存在?
我知道它不正确,但我一直在使用以下代码:
if($('div#mainContainer div.active div[data-unique='+urlUnique+']').length > 0) {
从长远来看,会有很多 DIV,所以它需要查找是否存在具有此类和数据属性的 DIV。
谢谢
这是您想要的选择器:
$('#mainContainer div.active[data-popup=true]');