我即将使用 jquery 在 drupal 中制作一个菜单,我需要当它具有事件类时需要显示的链接。
(function ($) {
$(document).ready(function() {
$('.region-sidebar-first .block-menu ul.menu').children('li').children('a').hasClass('active').hide();
$('.region-sidebar-first .block-menu h2').click(function() {
$(this).parent().siblings().children().next().children().slideUp(400);
$(this).next('.content').children('.menu').slideDown(400);
});
});
}(jQuery));
最佳答案
你需要使用jquery hasClass()
完整信息在这里:http://api.jquery.com/hasClass/
if ($('#item1').hasClass("active")) {
DoSomething()
} else {
DoSomethingElse()
}
您还可以使用:visible
if ($('#item1:visible')) {
DoSomething()
} else {
DoSomethingElse()
}
关于javascript - Jquery hasClass 显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7964730/