如何制作jQuery UI手风琴切换

时间:2011-05-20 13:02:34

标签: jquery jquery-ui

手风琴本身很容易切换,我不得不使用jQuery的UI手风琴,因为它易于合并可收藏的链接。在这一点上,我可以得到一个手风琴效果(从头开始)切换到没有书签链接,或获得与UI的书签链接,没有切换。我希望能够折叠所有的手风琴内容,也就是说,如果你在展开后点击触发器 - 第二次点击会关闭它。这就是我所拥有的:

$(function() {
    //basic accordion settings
    $('#accWrap').accordion({
        active: false,
        alwaysOpen: false,
        autoHeight: false,
        navigation: true,
        collapsable: true,
        header: '.accButton'
    });

    //attempt at toggling - does not work correctly
    //$('.accButton').click(function() {
    //$(this).next().toggle();
    //return false;
    //}).next().hide();

    //bookmarkable function
    $(".accButton").click(function(event){
      window.location.hash=this.hash;
    });
});

任何人都会看到任何明显错误或者我可以合并切换功能的方式吗?一如既往,我感谢您的帮助!

THX

3 个答案:

答案 0 :(得分:8)

这是一个古老的话题,但由于我自己在寻找答案,并在jQuery UI accordion doc中找到了答案:

 <script>
    $(function() {
        $( "#accWrap" ).accordion({
            collapsible: true
        });
    });
 </script>

“可折叠”在您的代码中拼写错误,它缺少“i”。

答案 1 :(得分:0)

嗨,我不确定这是否是你想要实现的目标。但这就是我使用的..

未从here

中抢走
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function()
{
  //hide the all of the element with class msg_body
  $(".msg_body").hide();
  //toggle the componenet with class msg_body
  $(".hidebox_head").click(function()
  {
    $(this).next(".msg_body").slideToggle(600);
  });
});
</script>
</head>
<body>
<div class="msg_head">
click me</div>
<div class="msg_body">
alksdjf löaskdjf ölaskjdöflkjas dlfkj asödlk
</div>
</body>
</html>

答案 2 :(得分:0)

看起来你拼错了“可折叠”。尝试用“i”拼写“可折叠”。

相关问题