好吧,我想要的是单击菜单项时出现在菜单项下方的 div。
这是我的 HTML(取自 WordPress 源代码):
<li id="menu-item-990" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-top-level menu-item-top-level-7">
<a href="#" style="height: 88px; line-height: 88px;">
<span class="avia-bullet"></span>
<span class="avia-menu-text">Sign in</span>
<span class="avia-menu-fx">
<span class="avia-arrow-wrap">
<span class="avia-arrow"></span>
</span>
</span>
</a>
</li>
<div id="text-6" class="widget clearfix widget_text">
<h3 class="widgettitle">How to sign in</h3>
<div class="textwidget"></div>
</div>
还有一些 CSS(这应该是内联的,还是我应该在 JS 函数中应用一些 CSS?)
#text-6 { visibility: hidden; }
然后是我的 JS:
$(document).ready(function() {
$('#menu-item-990 a').click(function() {
event.preventDefault();
$('#text-6').slideToggle("fast");
});
});
我会很感激任何答案!希望你能帮忙:)
谢谢!
最佳答案
您在函数中忘记了参数 event
:
$(document).ready(function() {
$('#menu-item-990 a').click(function(event) {
event.preventDefault();
$('#text-6').slideToggle("fast");
});
});
关于javascript - 菜单 li anchor 上的 jQuery 单击功能 - slideToggle 不工作(WordPress),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30502350/