[英]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.