简体   繁体   中英

Sliding without hiding element?

Is there a way to animate new DOM elements without having to hide them first? If so, how?

For example, what I'm doing now is:

$(document).ready(function() {
    $(document).on("click", ".link", function(event) {
        event.preventDefault();
        var count = 1;
        $.ajax({
            url: 'php/get_data.php',
            type: 'POST',
            dataType: 'json',
            data: { total_count: count  },
            success: function(data) {
                $(".new-elements").append(data).hide().slideDown(function() {
            }
        });
    });
});

Thanks.

是的,您尝试添加css(这些元素的默认设置),例如display: none或者,如果您更喜欢opacity: 0opacity: 0 ,则尝试对其进行动画处理。

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