Grow your CSS skills. Land your dream job.

jQuery toggleClass or addClass problem

  • # May 21, 2009 at 11:59 pm

    Hi everyone !
    I’m having some trouble with the jQuery library
    I would like to vanish some text when i click on a link
    I tried with addClass or toggleClass, but it doesn’t works
    I want to make disapear text included in the class .slot_text
    here is my code
    ( sorry for my english , i’m very bad)

    # May 21, 2009 at 11:59 pm

    // html

    <div id="conteneur" class="container">

    <div class="span-24 last"><br /><br /><br /><br /><br /><br />
    </div>

    <div class="span-10 last prepend-5" id="box1">
    <div class="span-4 slot_img" >
    <img src="../../../data/img/square/png/burn_typo.png" />

    </div>

    <div class="span-6 last slot_text" >
    <div class="span-6 ">
    Burning is outrageous <br /><br />
    </div>
    <div class="span-6 last">
    <p>
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    </p>
    </div>
    </div>
    </div> <!– fin #box1 –>

    # May 22, 2009 at 12:00 am

    // css

    .disable{
    display: none;
    }

    # May 22, 2009 at 12:01 am

    // js

    $(function() {
    (‘a#link’).click(function(){
    (‘.slot_text’).toggleClass(‘disable’);
    });
    });

    # May 22, 2009 at 12:04 am

    Thanks for your help :)

    ps : i’m workink with blueprintcss

    # May 22, 2009 at 6:00 am

    Why bother with adding and removing classes when you can use the hide function instead?

    Code:
    $(function() {
    (‘a#link’).click(function(){
    (‘.slot_text’).hide();
    });
    });
    # May 22, 2009 at 7:22 am

    Thanks Apostrophe !
    In fact, i would to make an effect like that : http://www.sohtanaka.com/web-design/exa … ay-switch/
    But i use, blueprintcss, i can’t switch the css style
    so i would like to make the text disapear, then to align pictures
    i thought making a class .slot_text to make it disapears, and anoter class with images already align but none display and to make appear this last one !

    thanks

    # May 22, 2009 at 2:47 pm

    You wouldnt be changing the css at all. you would simply change the display value to none. it does not alter the css file in any way. simply set a display: none property to the element

    # May 23, 2009 at 5:44 am

    i get it Stack ! cheers

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

You must be logged in to reply to this topic.

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