[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

Jquery simple accordion using a list

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
catonthecouchproductions
Asked:
catonthecouchproductions
  • 11
  • 9
1 Solution
 
Gurvinder Pal SinghCommented:
Your css is not showing there.
By the way, which class you want to add and remove and on which event
0
 
catonthecouchproductionsAuthor Commented:
Updated my CSS via the link, sorry!

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

And on the click event.
0
 
Gurvinder Pal SinghCommented:
<<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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
catonthecouchproductionsAuthor Commented:
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
 
Gurvinder Pal SinghCommented:
And css is still not there!! :)
0
 
catonthecouchproductionsAuthor Commented:
Ah, hit run instead of update, try it out now! http://jsfiddle.net/nhDxH/1/

Thanks.
0
 
Gurvinder Pal SinghCommented:
i have done some updation, please check.

Please let me know what exactly is the requirement
0
 
catonthecouchproductionsAuthor Commented:
Close! Can you get the "active" class on to attach to the LI tag on click?
0
 
Gurvinder Pal SinghCommented:
check now
0
 
catonthecouchproductionsAuthor Commented:
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
 
Gurvinder Pal SinghCommented:
check again, now only adding to parent li
0
 
catonthecouchproductionsAuthor Commented:
I think fiddle is adding new links for each revision can you send me the copy you're working on?
0
 
Gurvinder Pal SinghCommented:
0
 
catonthecouchproductionsAuthor Commented:
Awesome! thank you.
0
 
catonthecouchproductionsAuthor Commented:
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
 
catonthecouchproductionsAuthor Commented:
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
 
Gurvinder Pal SinghCommented:
why no point for me??
0
 
catonthecouchproductionsAuthor Commented:
No i did! It was a mistake, clicked the wrong button :) clicked my own. You should be good now.
0
 
catonthecouchproductionsAuthor Commented:
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
 
Gurvinder Pal SinghCommented:
<< 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

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 11
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now