Solved

Jquery simple accordion using a list

Posted on 2011-09-08
22
382 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now