The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Appending class to existing class that is the same as $(this) class?

  • # November 13, 2012 at 7:32 am

    Here be the CodePen:

    I’m trying to append a class of active to a div that has the same class as the id of the span being clicked.

    Can’t seem to get this to get working.

    Basically the intention is to click the boxes and then it makes the input boxes appear.

    Any ideas? I can do it manually for each div/span pair but I want to make a single function that covers every one because there will be 7 different div/span pairs.

    # November 13, 2012 at 7:37 am

    This reply has been reported for inappropriate content.

    Never mind – fixed that bad boy.

    Basically I was messing it up myself by having the $(this).addClass(“completed”); before the main function – thereby making it use “completed” as the class – which was the wrong one :)

    Fixed Codepen in case anyone comes across the same issue.

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

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed