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

    http://jsfiddle.net/Mottie/3DMue/25/

    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?

    http://jsfiddle.net/tovic/3DMue/27/

    # 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

    Firefox.

    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();
    $('#area').append('

    ' + $.trim(paragraph) + '

    ');
    removing();
    });
    # 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?

        $('a.plus').click(function(){
    $(this).parent().before('
  • The List
  • ');
    return false;
    });
    $('a.minus').click(function(){
    $(this).parent().before().remove();
    return false;
    });

    http://jsfiddle.net/tovic/3DMue/29/ (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: http://jsfiddle.net/tovic/3DMue/30/

    # December 28, 2011 at 9:53 pm

    $(this).parent().prev().remove();

    # December 29, 2011 at 1:39 am

    OOOOOOOOHHHHHHHHH!!! :(o)
    http://jsfiddle.net/tovic/3DMue/31/

    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*;
    blah.click(function(){
    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

    Okay!

    # 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: http://stackoverflow.com/questions/2970196/use-jquery-to-keep-adding-numbers-to-a-variable-on-click

        $('a.plus').live("click", function(){
    var n = $(this).parent().length;
    $(this).parent().before('
  • 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.

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