Solved

Jquery simple accordion using a list

Posted on 2011-09-08
22
384 Views
Last Modified: 2012-05-12
Hi,

I am trying to create a simple jQuery accordion using the code here: http://jsfiddle.net/nhDxH/

The biggest issue I am having is adding/removing the class when I select an item. I can get the lists to hide/show. Any suggestions?

I would like to set the active class on the LI

Thanks,

Ryan
0
Comment
  • 11
  • 9
22 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36503764
Your css is not showing there.
By the way, which class you want to add and remove and on which event
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36503776
Updated my CSS via the link, sorry!

I am trying to add ".active" to li.active

And on the click event.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36503788
<<I am trying to add ".active" to li.active>>

You mean to say that if you already have a class active on li, you want to add it again?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36503798
No I was writing out that the ".active" is being attached to a LI tag. On click of A add class "active" to the parent LI
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36503800
And css is still not there!! :)
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36503809
Ah, hit run instead of update, try it out now! http://jsfiddle.net/nhDxH/1/

Thanks.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36503888
i have done some updation, please check.

Please let me know what exactly is the requirement
0
 
LVL 1

Accepted Solution

by:
catonthecouchproductions earned 500 total points
ID: 36503912
Close! Can you get the "active" class on to attach to the LI tag on click?
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36503965
check now
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36503974
I still see the class being added to the <a> not the <li>

If its easier we can have the click event on the <li> so:

$('.ski_category').click(function() {
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36503999
check again, now only adding to parent li
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36504010
I think fiddle is adding new links for each revision can you send me the copy you're working on?
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36504026
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36504033
Awesome! thank you.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36504041
I've requested that this question be closed as follows:

Accepted answer: 0 points for catonthecouchproductions's comment http:/Q_27297912.html#36504033

for the following reason:

Speedy and patient!
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36504042
Can we reverse this? I clicked the wrong comment and didnt mean to flag it. This question was perfect and the expert helped me with that I needed. If we can reopen and I can award points, please.

Thanks,

Ryan
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36504051
why no point for me??
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36504057
No i did! It was a mistake, clicked the wrong button :) clicked my own. You should be good now.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36504449
One quick thing I just noticed! http://jsfiddle.net/nhDxH/7/ - click one of the child elements in side the list. the active gets added to that as well. It should have just been that parent LI
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36515246
<< Close! Can you get the "active" class on to attach to the LI tag on click?>>
In this comment #36503912, you mentioned that you want the active to be attached to li tag on click.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Explain how this javascript function works 1 47
simple javascript form validation 2 20
How do I pull the base url for use in html links 7 23
replace link with jQuery 4 15
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question