简体   繁体   中英

jquery slider toggle animation not working

im trying to get my slider to work. I know how I could make one, but i am trying to use toggle() .. it has proven to be quite difficult, does anyone know anything i dont?

http://jsfiddle.net/kr2wE/

$("#slider").on("click", function () {
    $("#slider").toggle(function () {
        $(this).animate({
            "height":"100px"
        }, 1000);
    }, function () {
        $(this).animate({
            "height":"0"
        }, 1000);
    });
});
$("#slider").toggle(function () {
    $(this).animate({
        "height":"100px"
    }, 1000);
}, function () {
    $(this).animate({
        "height":"20px"
    }, 1000);
});

The correct version of this form is this

Note: This function was deprecated in jQuery 1.8 and removed in 1.9 https://api.jquery.com/toggle-event/ . So I would strongly advise you not to use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM