如何使用元素ID激活accordion标头?

时间:2014-08-04 19:27:06

标签: jquery html accordion jquery-ui-accordion

我在尝试根据ID而不是实际元素激活标头时遇到问题。任何人都可以帮助我......这就是我现在所拥有的......

$(function() {
  $( "#accordion" ).accordion({ collapsible: true, active: false, 
        animate:50, header: "#cat" });    
});

<div id="accordion">
    <div id="cat">Pizza </div>

    <div> Regular Cheese Pizza </div>
    <div> Regular Cheese Pizza </div>
</div>

1 个答案:

答案 0 :(得分:0)

没关系。我想出了这个问题。我需要将所有内容包装在一个div子元素周围,如此

    $( "#accordion" ).accordion({ collapsible: true, active: false, animate:50, header: "#cat" });

        });





    </script>
</head>
<body>




<div id="accordion">
<div id='cat'>Pizza </div>

<div>

<div>Pizza</div>
<div>Pepperoni Pizza</div>

</div>



</div>