【问题标题】:jQuery animate duration not workingjQuery动画持续时间不起作用
【发布时间】:2013-01-10 23:28:27
【问题描述】:

通过在这里解决所有类似的问题,我对我的 jQuery 动画持续时间失败的代码有疑问。我的目的是使用 ajax 从 DB 中提取长内容并填充 div,然后将 div 扩展到适当的高度。非常欢迎您指出我的理论中任何不足之处。但是当回到持续时间失败时,它根本不起作用,我找不到原因。

$('.button_expand_news').click(function() {
    $(this).text('LOADING...');
    var pod = $(this).prev();
    var id = $(this).attr('id');
    $.ajax({
        url: 'func.blogs.php?p=loadNews&id=' + id,
        dataType: 'json',
        success: function(response) {
            var content = response['full_content'];
            pod.html('');
            pod.html(content);
            pod.animate({
                height: '100%'
            }, 500, function() {
                $(this).next().text('COLLAPSE');
            });
        }
    });
}

演示页面可以参考my project site

【问题讨论】:

  • 您意识到您的测试站点将动画持续时间设置为 0 对吗? tiams.0zed.com/lib/news.js
  • 是的 Rick,即使持续时间设置为 1000,它也不起作用。所以我将其设置为零以节省系统资源。

标签: jquery jquery-animate duration


【解决方案1】:

这是一个猜测:

你是否在你的 CSS 中设置了 height : 0 和 overflow:hidden 的“pod” div?

如果是,下一个猜测

替换

 height: '100%'

 height:pod.parent().innerHeight()

【讨论】:

    猜你喜欢
    • 2023-03-23
    • 1970-01-01
    • 2017-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    • 2013-03-16
    相关资源
    最近更新 更多