Treehouse: Grow your CSS skills. Land your dream job.

[Solved] Add Class to Parent if Checkbox is Checked

  • # December 24, 2011 at 3:57 am

    I hope that I can make Lorem Ipsum Generator with JQuery :p
    Until then and then I thought: “Does anyone want to add and subtract paragraphs then copy it while they can copy a paragraph with the classic way”.

    At that time I decided to add paragraphs, tables, headings and other inside

    by default, so JQuery only serve to modification, not as a main actor in the generator. But when I add an element with my generator rules the elements that I put in it all messszzz!!! (only the
    tag), Whether I’ve inserted it correctly according to the rules in the generator. *sigh*

    # December 24, 2011 at 9:46 am

    Merry Christmas

    # December 26, 2011 at 8:52 pm

    WOW! But why the of the original elements position are different with the inserted paragraph?

    PS: Am I too perfectionist?

    # December 26, 2011 at 9:21 pm

    When I add a new paragraph, it looks exactly the same as the other ones already in there… which browser are you using? I just checked it on Firefox and Chrome.

    I’m a perfectionist too (a lazy one really), but it sounds like you might be running into a css problem.

    # December 27, 2011 at 12:23 am


    In inserted paragraph, the generated code will look like this:

    Blah blah blah blah blah

    but in the default paragraph will look like this:

    Blah blah blah blah blah

    # December 27, 2011 at 1:18 am

    You’re killing me! LOL

    Actually I had that fixed way back about 10 versions ago, but it didn’t get copied over or got removed in one of your updates. All it needed was the trim function seen below (demo)

        $('button#addParagraph').click(function() {
    var paragraph = $('textarea#pg').val();

    ' + $.trim(paragraph) + '

    # December 27, 2011 at 3:33 am

    WOW. It looks better. Thanks.
    I’ll go find out about .trim(). And will prepare the next question maybe :p

    # December 27, 2011 at 9:03 pm

    What’s wrong with my code?

  • The List
  • ');
    return false;
    return false;
    }); (Click add ordered/unordered list!)

    # December 28, 2011 at 9:49 am

    You’re killing me man!…

    Try using .live("click", function(){ instead of .click(function(){, because the list items don’t exist until you add them.

    # December 28, 2011 at 9:12 pm

    Work for the first trigger but not for the second:

    # December 28, 2011 at 9:53 pm


    # December 29, 2011 at 1:39 am


    Hey Mottie, Did you also feel that here’s too many .click() functions? Can I integrate them all in a bracket? For example like this:

    var blah = *this element*;{
    button#id1 = function(){
    button#id2 = function(){
    button#id3 = function(){


    # December 29, 2011 at 9:03 am

    Please, don’t fix stuff that isn’t broken.

    # December 29, 2011 at 8:34 pm


    # December 29, 2011 at 9:27 pm

    This may not be too important: How do I increase the number each time the list added. I hope I can also determine the amount of list to specify the beginning start counting. I’ve found the snippet but I was confused. I can’t determine this:

        $('').live("click", function(){
    var n = $(this).parent().length;
  • The List ' + (n + 1) + '
  • ');
    return false;
Viewing 15 posts - 16 through 30 (of 40 total)

You must be logged in to reply to this topic.