0

I've been thinking of making buttons to collapse sections of a resume I've put on a site online. I'm wondering if there's an accepted practice for making a section collapsible, or if I should just set the value of the divs to empty, and upon click, call a function that will fill the divs.

Would this be the best method, or are there better/more elegant methods?

2 Answers 2

3

The most common way to collapse content is to set the CSS property display to none:

// to collapse
myElement.style.display="none";
// to expand
myElement.style.display="block";

If you're using jQuery, it has hide and show to do this. As a bonus, you can also pass a duration to them and jQuery will animate it:

// to collapse with a 1000ms animation
myjQueryElement.hide(1000);
// to expand with a 1000ms animation
myjQueryElement.show(1000);
Sign up to request clarification or add additional context in comments.

1 Comment

Also with jQuery for an animated hide/show, see: api.jquery.com/slideToggle
1

My favourite script to use for collapsible div's is this one by Dynamic Drive,

Not only is it 'pretty' and user friendly but it is also so simple to implement, use and the script allows for all kinds of modifications :)

http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

2 Comments

Yeah that's just jQuery in action.
true true, it's great for people who dont know too much jquery though

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.