Solved

Jquery simple accordion using a list

Posted on 2011-09-08
22
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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