开发者

Make all jQuery Accordion sections always close on page load

I have download the jQuery Accordion for my site. I don't have any idea about jQuery. When the site opens all the sections of the accordion should close. I made some changes with these options...

-------------------------
//default
-------------------------
    jQuery().ready(function(){
        // simple accordion
        jQuery('#list1a').accordion();
        jQuery('#list1b').accordion({
            alwaysOpen: false,
            autoheight: true
        });
--------------------------
//Changed 
--------------------------
    jQuery().ready(functio开发者_运维知识库n(){
        // simple accordion
        jQuery('#list1a').accordion();
        jQuery('#list1b').accordion({
            alwaysOpen: true,
            autoheight: false
        });

<--------------------------->

but it's not working.


I think you want this:

jQuery().ready(function(){
    // simple accordion
    jQuery('#list1a').accordion();
    jQuery('#list1b').accordion({
        alwaysOpen: false,
        active: false
    });


I would recommend using the jQuery UI Accordion: http://jqueryui.com/demos/accordion/

You can start it with just one line:

$(function(){ $('.accordion').accordion() });

You can select all elements to start closed with the active option set to false and collapsible set to true:

$(function(){ $('.accordion').accordion({ collapsible: true, active: false }) });

Hope that works.


Maybe you don't have the $(document).ready(function(){....}); in your script code? More reading

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜