jQuery 手风琴:链接不起作用 [英] jQuery Accordion: links don't work

查看:29
本文介绍了jQuery 手风琴:链接不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery 的 accordion UI 元素处理页面.我在该示例中为我的 HTML 建模,除了在 <li> 元素中,我有一些无序列表的链接.像这样:

I'm working on a page using jQuery's accordion UI element. I modeled my HTML on that example, except that inside the <li> elements, I have some unordered lists of links. Like this:

  $(document).ready(function() {
     $(".ui-accordion-container").accordion(
        {active: "a.default", alwaysOpen: true, autoHeight: false}
     );
  });

  <ul class="ui-accordion-container">
  <li> <!-- Start accordion section -->
   <a href='#' class="accordion-label">A Group of Links</a>
   <ul class="linklist">
      <li><a href="http://example.com">Example Link</a></li>
      <li><a href="http://example.com">Example Link</a></li>
   </ul>

   <!--and of course there's another group -->

问题:链接无效

在我测试过的所有浏览器中,这些手风琴菜单中的链接会导致手风琴部分折叠,而不是将您带到链接页面.(我仍然可以右键单击并转到链接的站点.)

Problem: Links don't work

In all browsers I've tested, the links in those accordion menus cause the accordion section to collapse instead of taking you to the linked page. (I can still right-click and go to the linked site.)

这可能是某种点击绑定问题吗?

Could this be some kind of click binding issue?

推荐答案

默认情况下,accordian 小部件将所有链接设置为标题.要更改它,您需要使用 headers 选项指定一个选择器.因此,您的代码将如下所示:

By default, the accordian widget sets all the links to headers. To change it, you need to specify a selector with the headers option. So, your code would look like this:

$(".ui-accordion-container").accordion(
   { active: "a.default", ...,  header: "a.accordion-label" }
);

这篇关于jQuery 手风琴:链接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆