Prefijo Sustantivo
Prefijo Sustantivo

Reputation: 525

how to hide a jquery accordion block

1 - I have a jquery accordion with 3 panels.

2- I need to hide, via js, any given panel.

3 - On the internet, i've found this script, it works very well for panels other than the first

$('#myAccord').accordion().children('.ui-accordion-header:eq(index)').hide();

If you use this script on the first panel, a truncated line appears.

Is there a way to handle all cases, included the first panel?

<div id="myAccord">                 
    <b><img src="img1.png">option1</b>                      
    <div id="data1"></div>

    <b><img src="img2.png">option2</b>                      
    <div id="data2"></div>

    <b><img src="img3.png">option3</b>                      
    <div id="data3"></div>
</div>

$("#myAccord" ).accordion({
    heightStyle: "content",
    collapsible: true
});

Thanks

Upvotes: 2

Views: 4385

Answers (1)

Curtis Weeks
Curtis Weeks

Reputation: 325

Problem is .ui-accordion-header only hides the header and not the div itself. Best bet will be to hide each element explicitly:

$('#myAccord').accordion().children('b:eq(index), div:eq(index)').hide();

Upvotes: 4

Related Questions