• LINK1 ...">
    Geek Answers Handbook

    RemoveClass and Fade Animation

    I have this code

    <ul class="nav sub_nav_home">
        <li id="sub_nav_home1"><a href="#"><span>LINK1</span></a></li>
        <li id="sub_nav_home2"><a href="#"><span>LINK2</span></a></li>
        <li id="sub_nav_home3"><a href="#"><span>LINK3</span></a></li>
    </ul>
    
    $("ul.sub_nav_home li").hover(function() {
        $(this).removeClass("current").fadeOut();
    });
    

    This does not seem to display the animation I was after. This means that the li completely disappears.

    Basically I need to remove the β€œcurrent” class with the fade effect and then add it to the next β€œli” with the fade effect

    thank

    +5
    jquery
    user Nov 24 '10 at 15:19
    source share
    4 answers

    Not sure if you can do this with direct jQuery, but I know that the jQuery user interface has a modified removeClass () that allows you to add duration to remove the jQuery UI Docs class

    +6
    Cubed eye Nov 24 '10 at 15:23
    source share

    . jQuery, .animate().

    li, .next().

    +3
    simshaun 24 . '10 15:22

    AFAIK I don't think you can add fadeOut () to removeClass (). Someone will correct me if I am wrong!

    +1
    benhowdle89 Nov 24 '10 at 15:23
    source share

    Yes, you can do it with CSS3.

    You just add the following to .current.

    .current{
        color: #f00;
        background-color: #000;
        transition: color 0.5s, background-color 0.5s;
        -webkit-transition: color 0.5s, background-color 0.5s; /* Safari */
    }
    

    Obviously, you need to change the color / background color to the attributes you want to animate. Otherwise, the Cubed Eye suggestion including JqueryUI is great, since removeClass in jQueryUI will do all this for you.

    0
    davewasthere Jul 24 '13 at 12:09
    source share

    More articles:

    • Microsoft Standard / Coding Reference? - .net
    • What is the difference between "$ ^ N" and "$ +"? - variables
    • Ruby equivalent of javascript self-starting function - javascript
    • Perspective size reduction calculation - language-agnostic
    • Securing a devel grails application with a single htpasswd like password - security
    • Precompiling Jsp files at run time - java
    • The SelectTemplate () parameters of the custom DataTemplateSelector are not passed. What for? - c #
    • Why does the SelectTemplate method run 2 times in debug mode? - css-selectors
    • Development headers not found "when starting the installer of apache 2 modules for passengers, but they are installed - apache2
    • Canvas: attempt to use recycled bitmap android.graphics.Bitmap - garbage-collection

    All Articles

    Geek Answers | 2019