Jquery PreventDefault 与 drupal 菜单
我在 drupal 中有页脚菜单,其中包含很多菜单项。
<ul class="menu">
<li class="expanded first business">
<a title="" href="/content/business-tab">Business</a>
<ul class="menu">
<li class="leaf first about_business_mobile">
<a title="" href="/content/about-business-mobile">About Business Mobile</a>
</li>
<li class="leaf business_mobile_solutions">
<a title="" href="/content/business-pay-monthly">Business Mobile Solutions</a>
</li>
<li class="leaf value_packs">
<a title="" href="/content/business-value-packs">Value Packs</a>
</li>
<li class="leaf mobile_broadband">
<a title="" href="/content/mobile-broadband">Mobile Broadband</a>
</li>
<li class="leaf handsets">
<a title="" href="/content/handsets">Handsets</a>
</li>
<li class="leaf overseas_roaming">
<a title="" href="/content/overseas-roaming">Overseas Roaming</a>
</li>
<li class="leaf last overseas_calling_rates">
<a title="" href="/content/overseas-calling-rates">Overseas Calling Rates</a>
</li>
</ul>
</li>
<li class="expanded personal">
<a title="" href="/content/personal">Personal</a>
<ul class="menu">
<li class="leaf first about_personal_mobile">
<a title="" href="/content/personal-prepay">About Personal Mobile</a>
</li>
<li class="leaf personal_mobile_solutions">
<a title="" href="/content/personal-prepay">Personal Mobile Solutions</a>
</li>
<li class="leaf value_packs">
<a title="" href="/content/additional-packs-0">Value Packs</a>
</li>
<li class="leaf mobile_broadband">
<a title="" href="/content/mobile-broadband">Mobile Broadband</a>
</li>
<li class="leaf handsets">
<a title="" href="/content/handsets">Handsets</a>
</li>
<li class="leaf overseas_roaming">
<a title="" href="/content/overseas-roaming">Overseas Roaming</a>
</li>
<li class="leaf last overseas_calling_rates">
<a title="" href="/content/overseas-calling-rates">Overseas Calling Rates</a>
</li>
</ul>
</li>
</ul>
这只是菜单的第一行。我想要的是,当我单击“商务”菜单时,什么也不会发生。为此,我使用了 Jquery PreventDefault 函数。
$('#footer li.expanded a:first-child').click(function(e) {
e.preventDefault;
});
但是,当我执行脚本时,它只是停止扩展菜单下每个链接的工作。
I have footer menu in drupal which contains so many menu items.
<ul class="menu">
<li class="expanded first business">
<a title="" href="/content/business-tab">Business</a>
<ul class="menu">
<li class="leaf first about_business_mobile">
<a title="" href="/content/about-business-mobile">About Business Mobile</a>
</li>
<li class="leaf business_mobile_solutions">
<a title="" href="/content/business-pay-monthly">Business Mobile Solutions</a>
</li>
<li class="leaf value_packs">
<a title="" href="/content/business-value-packs">Value Packs</a>
</li>
<li class="leaf mobile_broadband">
<a title="" href="/content/mobile-broadband">Mobile Broadband</a>
</li>
<li class="leaf handsets">
<a title="" href="/content/handsets">Handsets</a>
</li>
<li class="leaf overseas_roaming">
<a title="" href="/content/overseas-roaming">Overseas Roaming</a>
</li>
<li class="leaf last overseas_calling_rates">
<a title="" href="/content/overseas-calling-rates">Overseas Calling Rates</a>
</li>
</ul>
</li>
<li class="expanded personal">
<a title="" href="/content/personal">Personal</a>
<ul class="menu">
<li class="leaf first about_personal_mobile">
<a title="" href="/content/personal-prepay">About Personal Mobile</a>
</li>
<li class="leaf personal_mobile_solutions">
<a title="" href="/content/personal-prepay">Personal Mobile Solutions</a>
</li>
<li class="leaf value_packs">
<a title="" href="/content/additional-packs-0">Value Packs</a>
</li>
<li class="leaf mobile_broadband">
<a title="" href="/content/mobile-broadband">Mobile Broadband</a>
</li>
<li class="leaf handsets">
<a title="" href="/content/handsets">Handsets</a>
</li>
<li class="leaf overseas_roaming">
<a title="" href="/content/overseas-roaming">Overseas Roaming</a>
</li>
<li class="leaf last overseas_calling_rates">
<a title="" href="/content/overseas-calling-rates">Overseas Calling Rates</a>
</li>
</ul>
</li>
</ul>
This is just the first li of the menu. What I want is, when I click on Business menu nothing will happen. So for this I used Jquery preventDefault function.
$('#footer li.expanded a:first-child').click(function(e) {
e.preventDefault;
});
But when I execute the script it just stops working of every links under the expanded menu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以做到:
This should do it: