treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] add removing class on click once and again.

  • howcome it doesn’t work with .click but it works with hover? it doesn’t make sense. what i want is when you hover over a list item, then there’s the hover color, then when you click i have a div appear (sliding down) then i want the LI #Show to have a yellow background-color then when clicked again the div goes away Display:hidden) and then i want the LI#Show to go back to its regular state. but i canonly get so far. where if the li is clicked once, then the div appears and the li background goes yellow, but once i click it again the div dissappears but the color does not go away.

    http://css-tricks.com/snippets/jquery/addingremoving-class-on-hover/
  • what do you have so far?
  • $('#elm').click(function(){
    $(this).toggleClass('active');
    });
  • OH MY GOODNESS thank you soo much! i had no idea you could toggle a CLASS! wow. love jQuery. still learning. :) well.. just learning haha. but thank you so much. much appreciated.
  • I was going to submit a response as I thought I had a good answer. I too did not know of 'toggleClass()'

    +1 for learning!