Make accordeon/toggle menu using jquery or javascript

Posted by Souza on Stack Overflow See other posts from Stack Overflow or by Souza
Published on 2012-07-06T02:15:47Z Indexed on 2012/07/06 3:15 UTC
Read the original article Hit count: 244

Filed under:
|
|

Found a solution:

$('div.divname').not(':eq(0)').hide();

Check this page:

http://www.iloja.pt/index.php?_a=viewDoc&docId=19

I would like to have ONLY the first text (faqtexto) open, and the one bellow, hidden on loading (by default)

This is the HTML:

    <div class="agendarfaq">
        <div class="topfaq"></div>

        <div class="faqtopics"><p class="textopics">Recolha e entrega, quanto tempo?</p></div>
        <div class="faqtexto"> Neque porro quisquam est, qui dolorem   ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem</div>

        <div class="faqtopics"><p class="textopics">Recolha e entrega, quanto tempo?</p></div>
        <div class="faqtexto"> Neque porro quisquam est, qui dolorem   ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem</div>
    </div>

The jQuery I propose:

$(".faqtopics").click(function(event) {
    $("div.faqtexto").slideUp(100);
    $(this).next("div.faqtexto").slideToggle();
});

Do you suggest any other cleaner jQuery code?

Any help would be welcome! Thank you very much!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery