0

I'm using jquery's animatedcollapse for the FAQ section of my site, as a way to keep things tidy.

I have all the div's closed by default, but is there a way to have 1 specific div opened if I call the id with a URL query parameter?

The url I am referring to is: http://www.carcityofdanbury.com/?cat=02&do=FAQ meaning if I have a link to http://www.carcityofdanbury.com/?cat=02&do=FAQ#id=4 when the page loads can I have all the div's except #4 closed?

I've searched Google and cant find an answer for this.

Thank you.

2 Answers 2

0

Stick to all div's that you have attribute data-id = , then on $(document).ready() hide all div's that dont equal to 4

$(document).ready(function(){
    $all_divs = $('#div');
    $all_divs.each(function(){
       if ($(this).attr("data-id") != 4) {
           $(this).hide();
       }
    });
});
Sign up to request clarification or add additional context in comments.

Comments

0

Use the method outlined here - http://www.dynamicdrive.com/dynamicindex17/animatedcollapse_suppliment2.htm

For example - http://www.carcityofdanbury.com/?cat=02&do=FAQ&expanddiv=10004

Please note that your element IDs should not start with a number. See HTML & XHTML id attribute question.

I'd also recommend you check out a more up-to-date plugin (dynamic drive, seriously?). Try the Twitter Bootstrap Collapse plugin.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.