Binding For-Each to JQuery Accordion

2019-08-24 07:14发布

I want to create an accordion UI using a for each loop. I have the following code so far...

HTML

<div id="accordion" data-bind="foreach: fixtures">
   <h3><a href="#" data-bind="text: name"></a></h3>
   <div>Information</div>
</div>

JAVASCRIPT

$("#accordion").accordion({ header: "h3", collapsible: true, active: true});

Any clues as to where this is going wrong?

1条回答
Fickle 薄情
2楼-- · 2019-08-24 07:56

Put inside $(document).ready(function () {...

$(document).ready(function () {
    ...
    $("#accordion").accordion({ header: "h3", collapsible: true, active: true });
});
查看更多
登录 后发表回答