Skip to content Skip to sidebar Skip to footer

Jquery Accordion, Set Active By Id

So I have tried everything and cannot seem to figure this out, what I have is an accordian that plugs in data dynamicly, what I need to happen is I need the id of the data to be pl

Solution 1:

On the accordion I use in my project, I just set the active to "h3#" + the id of the accordion fold I want to open.

<scripttype='text/javascript'>jQuery(function() {
    jQuery( "#work" ).accordion({
    collapsible: true,
    active: "h3#id"
    });
});
</script>

I believe its the standard jQueryUI accordion, so hopefully it will work for you too.

Solution 2:

For anyone else who came across this older topic, jQuery Accordion now uses a number based value for the "active" option > https://api.jqueryui.com/accordion/#option-active > 0 = the first accordion tab > 1 = the second accordion tab etc. active: 1 will display the second accordion tab open/active. Additionally you probably want to use the autoHeight, clearStyle and heightStyle options so that you do not have additional whitespace at the bottom of the active accordion tab.

<scripttype="text/javascript">/* <![CDATA[ */jQuery(document).ready(function($){
    $( "#accordion" ).accordion({
    collapsible: true,
    active: 1,
    autoHeight: true,
    clearStyle: true,
    heightStyle: "content"
    });
});
/* ]]> */</script>

Post a Comment for "Jquery Accordion, Set Active By Id"