用于打开 jQuery Accordion 的链接 [英] Link to open jQuery Accordion

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

问题描述

我正在尝试从外部链接打开一个手风琴 div.我看到了navigation: true"选项,但我不确定如何实现它.你给每个 div 一个 id 并像这样调用链接吗?http://domain.com/link#anchorid

我是 jQuery 新手,请耐心等待.如果有帮助,这是我正在使用的代码.

<div id="手风琴"><div><h2><a href="#">服务</a></h2><div class="services"><p>关于所有这些服务的更多信息</p>

解决方案

导航选项不适用于面板激活.这是为了告诉用户他们在哪里.

使用简化的 html 代码:

<div><h2><a href="#services">服务</a></h2><p>关于所有这些服务的更多信息</p>

<div><h2><a href="#about">关于</a></h2><p>关于我们</p>

您将唯一 ID 放在标题中的超链接中

然后是 jQuery(简化版):

navigation : true"将使您能够访问 www.site.com/#about,从而选择about"面板.对于激活,有几种方法.也许一种方法是获取查询字符串并将其放入 jQuery.

使用 C#

$("#accordion").accordion("activate", '<%= Request.QueryString["id"] %>');

使用 PHP

$("#accordion").accordion("activate", '<?php echo $_GET['id']; ?>');

哪个将允许您指定通过 www.site.com?id=2 打开哪个面板

I'm trying to open an accordion div from an external link. I see the "navigation: true" option but I'm not sure how to implement it. Do you give each div an id and call the link like this? http://domain.com/link#anchorid

I'm new to jQuery so bear with me. Here is the code I'm using if it helps.

<script type="text/javascript">
    $(function(){
        $("#accordion").accordion({ header: "h2", autoHeight: false, animated: false, navigation: true });
         });
    </script>
<div id="accordion">

<div>
    <h2><a href="#">Services</a></h2>
    <div class="services">
    <p>More information about all of these services</p>
    </div>
</div>

解决方案

The navigation option isn't for panel activation. It's for telling the user where they are.

Using simplified html code:

<div id="accordion">

    <div>
        <h2><a href="#services">Services</a></h2>
        <p>More information about all of these services</p>
    </div>

    <div>
        <h2><a href="#about">About</a></h2>
        <p>About us</p>
    </div>

</div>

You put the unique ID in the Hyperlink in the title

Then the jQuery (simplified):

<script type="text/javascript">
    $(function(){
        $("#accordion").accordion({ header: "h2", navigation: true });
     });
</script>

The "navigation : true" will enable you to go www.site.com/#about which makes the "about" panel selected. For activation, there are a couple of ways. Perhaps one way is to grab a query string and put it into the jQuery.

With C#

$("#accordion").accordion("activate", '<%= Request.QueryString["id"] %>');

With PHP

$("#accordion").accordion("activate", '<?php echo $_GET['id']; ?>');

Which will allow you to specify which panel to open by www.site.com?id=2

这篇关于用于打开 jQuery Accordion 的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆