我使用的是jquery手风琴(Jquery 1.9 / Jquery-ui-1.10.1)。我想从带有锚标记的外部页面链接到该页面。当使用锚标签时,我想打开手风琴上的特定面板。例如,如果我传递#panel2锚标记,我想打开并显示第二个面板。
我还在手风琴页面上有图像,还需要链接到手风琴中的特定面板。
任何人都可以帮忙吗?
答案 0 :(得分:6)
尝试:
HTML:
<a class="opener" data-panel="0" href="#">Open Section 1</a>
<a class="opener" data-panel="1" href="#">Open Section 2</a>
<a class="opener" data-panel="2" href="#">Open Section 3</a>
<a class="opener" data-panel="3" href="#">Open Section 4</a>
<div id="accordion">
<h3>Section 1</h3>
<div>
<p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo
ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
</div>
<h3>Section 2</h3>
<div>
<p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit
faucibus urna.</p>
</div>
<h3>Section 3</h3>
<div>
<p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia
ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
</div>
<h3>Section 4</h3>
<div>
<p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus
orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel
est.</p>
<p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
inceptos himenaeos.</p>
</div>
</div>
jQuery的:
var $accordion = $("#accordion");
$accordion.accordion();
$(".opener").on("click", function () {
var $this = $(this),
toOpen = $this.data("panel");
$accordion.accordion("option", "active", toOpen);
return false;
});
小提琴here