让 JQuery Accordion 滚动浏览所有窗格?
我想使用我的 JQuery Accordion,并在最后一个元素上开始打开它,让每个窗格相继下拉(以使用户清楚地知道还有其他内容窗格可供他们查看)。我可以使用 Accordion.accordion("activate", index) 来更改打开的窗格,但它只能工作一次(连续调用似乎没有任何效果?)。
现在,下面的代码初始化手风琴并激活窗格一,但对窗格二没有任何影响。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Page</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.12.custom.min.js"></script>
<script type="text/javascript">
$(function () {
nyah = $("#accordion").accordion({
event: "mouseover",
animated: "bounceslide"
});
nyah.accordion("activate", 1);
for (var i = 0; i < 1000; i++) {
i++;
}
nyah.accordion("activate", 2);
});
</script>
</head>
<body>
<div id = "accordion">
<h3><a href="#">One</a></h3>
<div><img src="1.png" alt="" /></div>
<h3><a href="#">Two</a></h3>
<div><img src="2.jpg" alt="" /></div>
<h3><a href="#">Three</a></h3>
<div><img src="3.jpg" alt="" /></div>
</div>
</body>
</html>
I want to take my JQuery Accordion and, with it starting open on the last element, have each pane successively drop down (to make it clear to the user that there are other panes of content available for them to view). I can am using Accordion.accordion("activate", index) to change the open pane, but it only works once (successive calls don't seem to have any effect?).
Right now the code below initializes the accordion and activates pane one, but doesn't have any effect on pane two.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Page</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.12.custom.min.js"></script>
<script type="text/javascript">
$(function () {
nyah = $("#accordion").accordion({
event: "mouseover",
animated: "bounceslide"
});
nyah.accordion("activate", 1);
for (var i = 0; i < 1000; i++) {
i++;
}
nyah.accordion("activate", 2);
});
</script>
</head>
<body>
<div id = "accordion">
<h3><a href="#">One</a></h3>
<div><img src="1.png" alt="" /></div>
<h3><a href="#">Two</a></h3>
<div><img src="2.jpg" alt="" /></div>
<h3><a href="#">Three</a></h3>
<div><img src="3.jpg" alt="" /></div>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 setTimeout 这样的事情怎么样?我认为你的问题是你在第一次激活完成之前调用激活。
http://jsfiddle.net/xgFpD/1/
How about something like this using setTimeout. I think your problem is that you're calling activate before the first activate finishes.
http://jsfiddle.net/xgFpD/1/
它确实支持多次激活:http://jsfiddle.net/morrison/v2FCJ/。
但是,您的代码在第一个激活完成之前触发第二个激活。手风琴显然不支持排队命令。
It does support multiple activations: http://jsfiddle.net/morrison/v2FCJ/.
However, your code is triggering the second activate before the first one is done. The accordion does not apparently support queuing commands.