Jquery 如何在折叠的手风琴中创建指向项目的链接?
试图在包含折叠的手风琴项目的页面中创建链接,每个项目由div ID编号标识 通过向“我的链接”添加参数链接和打开特定项目的尝试失败,如下所示:Jquery 如何在折叠的手风琴中创建指向项目的链接?,jquery,hyperlink,jquery-ui-accordion,Jquery,Hyperlink,Jquery Ui Accordion,试图在包含折叠的手风琴项目的页面中创建链接,每个项目由div ID编号标识 通过向“我的链接”添加参数链接和打开特定项目的尝试失败,如下所示: sample.html#itemIdX // opens to the page but not the item sample.html?itemIdX // same result 项目使用H3类: 如何创建一个链接,使我的itemX具有扩展状态?这比看起来要复杂一些,因为这些链接并不容易理解,而且激活功能似乎也不像宣传的那样工作 从您的问题
sample.html#itemIdX // opens to the page but not the item
sample.html?itemIdX // same result
项目使用H3类:
如何创建一个链接,使我的itemX具有扩展状态?这比看起来要复杂一些,因为这些链接并不容易理解,而且激活功能似乎也不像宣传的那样工作 从您的问题来看,听起来您想通过引用div ID打开一个手风琴部分;您只能使用基于0的索引标识节,例如0=第一节,1=第二节等 话虽如此,这种方法将在以下方面发挥作用: 定义如下链接:
<a href="10387904_Accordion_link_2.html?openAccordionId=0">Open first item</a>
<a href="10387904_Accordion_link_2.html?openAccordionId=1">Open second item</a>
<a href="10387904_Accordion_link_2.html?openAccordionId=2">Open third item</a>
你在我的回答中运用了这个解决方案吗?
<a href="10387904_Accordion_link_2.html?openAccordionId=0">Open first item</a>
<a href="10387904_Accordion_link_2.html?openAccordionId=1">Open second item</a>
<a href="10387904_Accordion_link_2.html?openAccordionId=2">Open third item</a>
// Using the parseQueryString extension from
// http://paulgueller.com/2011/04/26/parse-the-querystring-with-jquery/
$.extend({
parseQuerystring: function () {
var nvpair = {};
var qs = window.location.search.replace('?', '');
var pairs = qs.split('&');
$.each(pairs, function (i, v) {
var pair = v.split('=');
nvpair[pair[0]] = pair[1];
});
return nvpair;
}
});
// Get the index of the section we want to open from the querystring.
var openAccordionId = parseInt($.parseQuerystring()["openAccordionId"]);
// Initialise the accordion with the active section defined.
var accordion = $("#accordion").accordion({ active: openAccordionId });
// Note: for some reason, the following does not work:
// var accordion = $("#accordion").accordion();
// accordion.activate(openAccordionId);