Grow your CSS skills. Land your dream job.

[Solved] ADD and remove class on click but remove class again on reclick

  • # May 21, 2012 at 6:12 pm

    okay here is what i want to happen i have a div right. so currently the div has a class of “cfse_a” however when the div with an id of #cf-search is clicked on i want to remove the class cfse_a and then add cfse_b then when the user clicks anything other then the div i want to remove the class cfse_b. Might seem confusing right take a look at youtube.com with google chrome then hover over the search box and inspect it you will see on hover it adds a class however on click it removes that class adds another class. Then when anything other then the search box is clicked the script removes the click class hope it’s not too confusing

    # May 21, 2012 at 7:07 pm

    As far as I can tell, this is what you are after: http://jsfiddle.net/joshnh/2rTRR/

    # May 22, 2012 at 12:05 pm

    thanks you solved my problem

    # May 22, 2012 at 6:37 pm

    No worries!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".