Wednesday, January 28, 2009

[jQuery] Re: paragraphs disappearing from accordion when jquery applied

Is this like, a test?

$(".accordion p:not(:first)").hide();

that line, why do you think no paragraphs are displaying after the first?


Steven Grant wrote:
> I'm trying to use the accordion box as show on
> http://www.webdesignerwall.com/demo/jquery/accordion1.html
>
> I'm using PL/SQL to pull my content from the database which it does
> perfectly.
>
> I then applied my CSS and it also displays the way I'd expect.
>
> However, when I add my jquery.js file and extra bit of code, the
> content displays with one exception; any paragraphs after the first
> don't display.
>
> My content is like so:
>
> [code]
> <div class="accordion">
> <h3>question</h3>
> <p>answer para 1</p>
> <p>answer para 2</p>
> <p>answer para 3</p>
> </div>
> [/code]However, after applying:
> [code]<script type="text/javascript">
> $(document).ready(function(){
>
> $(".accordion h3:first").addClass("active");
> $(".accordion p:not(:first)").hide();
>
> $(".accordion h3").click(function(){
> $(this).next("p").slideToggle("slow")
> .siblings("p:visible").slideUp("slow");
> $(this).toggleClass("active");
> $(this).siblings("h3").removeClass("active");
> });
>
> });
> </script>
> [/code]<p>answer para 2</p>
> <p>answer para 3</p>
>
> don't display.
>
> Any ideas why? It's an Intranet environment so apologies for lack of
> links.
>

No comments: