jquery dynamic content


I have an accordion style menu on the left hand side of my page with various links.

I want each link to reveal a div/section of content upon click. So all of the content makrup is loaded but hidden and depending on the link clicked it is revealed.

Is there any simple jquery I can use for this?

LVL 18
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Eternal_StudentConnect With a Mentor Author Commented:
Found a really good example here actually:

I recommend using Animated Collapse:


Very simple to use, you create hidden divs, and using this JavaScript code you'll be able to show them based on a click or based on any trigger you want.

I hope it helps you ;).
if you already use jQuery I would load page using AJAX  - so the initial loading the page won't be so heavy

checkout ajaxify

or using jquery BBQ

  it handles your back button nicely too

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

consider the following html
<div id="accordion">
    <h3><a href="#">First header</a></h3>
    <div id="acc1">First content</div>
    <h3><a href="#">Second header</a></h3>
    <div id="acc2">Second content</div>

Open in new window

the respective jquery script for handling ajax based display of items would be :-

	$('.accordion .head').click(function() {
	var nextId = $(this).next().id;
	  url: 'accodianData.asmx',
	  data: '{ selectedid : ' + nextId + ',
	  success: function(data) {
	    alert('Load was performed.');
		return false;

This is an illustration of what can be done to achieve your requirement.

Open in new window

Eternal_StudentAuthor Commented:
Could someone kindly provide a working example of a list of links that, when clicked, show only a section of content in the code at a time?
Eternal_StudentAuthor Commented:
I found what i need
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.