简体   繁体   English

如何选择类中具有特定元素的div?

[英]How to select div which has particular element in class?

How to hide a div if its class has particular element. 如果div的类具有特定元素,则如何隐藏它。 Here is my code. 这是我的代码。

<div id="admin-menu" class="admin-menu-site-localhost admin-menu-processed admin-menu-position-fixed" style="position: fixed;">
    <div id="admin-menu-wrapper"></div>
</div>

I need to select div with menu as element. 我需要选择div作为菜单元素。 Because menu is appended to some other element. 因为menu被附加到其他元素上。 How can I filter those div's? 如何过滤这些div?

UPDATE: I have tried the following, but it didn't work: 更新:我已经尝试了以下方法,但是没有用:

jQuery("body")hasClass("div[class*='menu']");

This should return all div elements that contains menu in className property: 这应该返回所有在className属性中包含menu div元素:

$('div[class*="menu"]')

or 要么

jQuery('div[class*="menu"]')

try this: 尝试这个:

$('[class*="menu"]').doSomething();

This will select any element that has menu in it's class list. 这将选择在其类列表中具有menu任何元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery如何查找具有特定操作的元素的类 - jQuery how to find class of an element which has a particular action 如何在div中找到具有Class的元素,而不是在jquery中 - how to find element in div which has Class and is NOT this in jquery 如何隐藏在JavaScript中的克隆元素上具有特定类的div - How to hide div which has specific class on cloned element in javascript 如何选择仅具有特定类别的元素? - How can I select an element which has only a specific class? 如何选择孩子<div>具有特定类名的 div 元素是使用 jQuery 的 DOM 中具有该类名的最后一个 div? - How to select the child <div> element of a div with a particular class-name that is the last div with that class-name in the DOM using jQuery? 选择具有特定类的元素的父级 - Select the parent of an element which has a certain class 如何为JQuery选择器选择属于类而不是类的所有元素的特定HTML元素 - how to select the particular HTML element which is part of a class and not all the elements of a class for JQuery selectors 如何检查.Attr元素是否具有特定类? - How to check if an element with .Attr has a particular class? 如何选择特定类的最后一个元素 - How to select last element of a particular class 如何使用&#39;this&#39;在jQuery类中选择特定元素 - How to select particular element with class in jQuery using 'this'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM